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 |
|
saurabhjj
Starting Member
13 Posts |
Posted - 2008-02-29 : 02:06:12
|
| hi,i have a table emp, whose primary key is empid(varchar2), i want to sort the empid and select the top row after sorting, i can sort the table using "select * from emp order by empid desc,i can select the top row using "select * from emp where rownum=1"i want a combination of the 2,pls provide me the required queryThanks and Regards,Saurabh Jhunjhunwala |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2008-02-29 : 02:13:42
|
| [code]select top 1 * from emp order by empid desc[/code]Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
saurabhjj
Starting Member
13 Posts |
Posted - 2008-02-29 : 02:16:02
|
| sorry the query you supplied did not work, |
 |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2008-02-29 : 02:18:26
|
| Well, then you should supply some information. Are you really using SQL Server? Which version? Where is sample data? What is the expected output?Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-02-29 : 02:38:36
|
This also looks like a ORACLE question.Microsoft SQL Server does not have a VARCHAR2 datatype. It has NVARCHAR. E 12°55'05.25"N 56°04'39.16" |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-02-29 : 05:29:36
|
| Select * from(select * from emp order by empid) twhere rownum=1Post oracle questions at www.orafaq.comMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|