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 - 2006-04-12 : 09:16:12
|
| Matthew writes "I'm trying to select unique rows from a table based on one field only to return only the first row of each job number.Example data:JobID Name Other~~~~~ ~~~~ ~~~~~5000 Buy things 165000 Go home 85002 Sumthing 45002 Daniel 100Needed Result:JobID Name Other~~~~~ ~~~~ ~~~~~5000 Buy things 165002 Sumthing 4I've tried using SELECT DISTICT but it checks all the fields which won't work.Any ideas?ThanksMatthew" |
|
|
chiragkhabaria
Master Smack Fu Yak Hacker
1907 Posts |
Posted - 2006-04-12 : 09:24:38
|
| Somthing like this Select Job, Max([Name]),Max(Other) From Tbl Group by Job ???If Debugging is the process of removing Bugs then i Guess programming should be process of Adding them. |
 |
|
|
Srinika
Master Smack Fu Yak Hacker
1378 Posts |
Posted - 2006-04-12 : 09:25:36
|
| How do u determine out of -------------------5000 Buy things 165000 Go home 8-------------------The one to be selected is-----------------------5000 Buy things 16-----------------------And not-----------------------5000 Go home 8-------------------Why I ask this is, in SQL server, it is not always the same order where u see the things, when it comes to different queries. If u want a particular order, u have to tell by which field(s) u want to sort and in ASCending or DESCending.Also the solution is not that hard if u r happy with any record from a particular Distinct JOBIDSrinika |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
|
|
|