SQL语句排序问题(100分)

  • 主题发起人 主题发起人 hbynjl
  • 开始时间 开始时间
H

hbynjl

Unregistered / Unconfirmed
GUEST, unregistred user!
数据表结构如下:年 &nbsp; &nbsp; 月 &nbsp; 日 &nbsp; 时 &nbsp; 分 &nbsp;...<br>&nbsp; &nbsp; &nbsp; 数据如下:2008 &nbsp; 5 &nbsp; &nbsp;12 &nbsp; 10 &nbsp; 10 &nbsp;... <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;2008 &nbsp; 5 &nbsp; &nbsp;12 &nbsp; 10 &nbsp; 10 &nbsp;..<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;2008 &nbsp; 5 &nbsp; &nbsp;12 &nbsp; 9 &nbsp; &nbsp;10 &nbsp; ..<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;2008 &nbsp; 5 &nbsp; &nbsp;12 &nbsp; 9 &nbsp; &nbsp;10 &nbsp; ..<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;2008 &nbsp; 5 &nbsp; &nbsp;12 &nbsp; 9 &nbsp; &nbsp;10 &nbsp; ..<br>要求在DBGRIDEH中能显示如下,并按照年月日时分排序:<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 年 &nbsp; &nbsp; 月 &nbsp; 日 &nbsp; 时 &nbsp; 分 其他字段<br>&nbsp; &nbsp; &nbsp; 数据如下:2008 &nbsp; 5 &nbsp; &nbsp;12 &nbsp; 9 &nbsp; 10 &nbsp; &nbsp;... <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ..<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ..<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;2008 &nbsp; 5 &nbsp; &nbsp;12 &nbsp; 10 &nbsp; &nbsp;10 &nbsp; ..<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;..<br>请帮忙,很急
 
select * from ... order by &nbsp;年, &nbsp; &nbsp; 月, &nbsp; 日, &nbsp; 时, &nbsp; 分
 
要求重复的年月日时分的值不显示,但不是整条记录不显示.
 
那就不要用DBGRIDEH自己一格一格画
 
1、DBGRIDEH 当数据感知控件用 方法:把记录集调整成你要的样子 (把与上条相同的时间字段都置为null 而且前提字段还要可为null)<br>2、DBGRIDEH当显示控件用(直接换stringgrid算了) 方法:一条一条插入grid时跟上一条对比<br><br>问题很明显,SQL语句还没只能到这样,就别在SQL上打主意了,转到显示记录上就不麻烦了
 
我觉得 可以先把 数据记录都查询出来按照年月日的顺序 ,然后再在Dbgrid中调整 ,不过似乎stringgrid灵活一些 ,可以试一下
 
后退
顶部