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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2004-04-27 : 08:55:03
|
| Hiren writes "Hi, I have a query which returns the results as follows:pk_col order_id out_dtm ----------- ----------- -------------------------1 10 2004-04-21 10:01:38.0002 10 2004-04-19 10:01:38.0003 9 2004-04-16 10:01:21.633I have these rows in the temp table. Now i want to get distinct order_ids in the order in which they appear. In above example i want 2 rows first with order_id = 10 and second with order_id = 9. So when i am executing following query : "SELECT distinct order_id FROM @temp_table" But this query gives result as follows :order_id ----------- 910So, here Distinct clause does the ordering on the column. Which I don't required. The same result appears when I do group by on that column.Need solution.Thanks,Hiren" |
|
|
derrickleggett
Pointy Haired Yak DBA
4184 Posts |
Posted - 2004-04-27 : 09:30:07
|
| GROUP BY DESCMeanOldDBAderrickleggett@hotmail.comWhen life gives you a lemon, fire the DBA. |
 |
|
|
|
|
|