Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
cplusplus
Aged Yak Warrior
567 Posts |
Posted - 2007-03-15 : 16:16:11
|
| I am doing sorting by GDR# and then Seq# via groupby clause in sql server stored proc.i get the data this way. GDR#(datatype is varchar) SEQ# datatype is REAL.GROUP BY GDRNO,SEQNO***************************GDR# - SEQ#---------------------------C0001 - 1.00C0002 - 1.00C0003 - 1.00C0001 - 2.00C0001 - 2.01**************************Can you please tell me what am i doing wrong, the last two records GDR# is C0001, how can the stored proc sql server get all C0001 related records first before it goes to C0002.Please help thank you very much. |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2007-03-15 : 16:26:28
|
| Your ORDER BY needs to specify both columns.GROUP BY GDRNO, SEQNO...ORDER BY GDRNO, SEQNOTara Kizerhttp://weblogs.sqlteam.com/tarad/ |
 |
|
|
cplusplus
Aged Yak Warrior
567 Posts |
Posted - 2007-03-15 : 16:34:37
|
Hello Tara,Can i have both Group By and Order by clauses in one single query execution, sql storedproc.or if i use order by clause, will i have to remove the group by clause.Thank you very much.quote: Originally posted by tkizer Your ORDER BY needs to specify both columns.GROUP BY GDRNO, SEQNO...ORDER BY GDRNO, SEQNOTara Kizerhttp://weblogs.sqlteam.com/tarad/
|
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2007-03-15 : 16:36:24
|
| Yes you can have both. The only want to guarantee a specific sort order is to specify ORDER BY.Tara Kizerhttp://weblogs.sqlteam.com/tarad/ |
 |
|
|
|
|
|