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 |
donjt81
Starting Member
11 Posts |
Posted - 2007-05-14 : 16:40:37
|
Hi,I am a newbie so this might be a very basic question. I have a table that not sorted. So I write a query to sort the table like this Select * from custInfo where custID <> '0' order by custID DescNow obviously I have a selection of the original table in desc order. Now I want to get the first custId from thid Desc selection. How do I do this.So if the unsorted table looked like this 001 Martha005 Steve002 Mike003 Davidand the sorted selection looks like this 005 Steve003 David002 Mike001 MarthaAnd then I want to select Steve's custID which is 005. how do i do this.Thanks in advance. |
|
blindman
Master Smack Fu Yak Hacker
2365 Posts |
Posted - 2007-05-14 : 17:12:22
|
Select TOP 1 * from custInfo where custID <> '0' order by custID Desce4 d5 xd5 Nf6 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-05-14 : 18:45:49
|
[code]Select max(custID) from custInfo where custID <> '0'[/code] KH |
|
|
|
|
|