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 |
azharrahi
Starting Member
44 Posts |
Posted - 2006-09-08 : 03:37:15
|
Hi all people I have a table NewsManagement. It has Three Columns "NewsID, Headline,Detail,Date". Now I want to retrieve the latest three records(i.e News), that is obviously with respect to date. That is If there are records from 2nd sep to 8 sep, and there are two records on 8 sep then it must retrieve THE TWO LATEST Records from 8 Sep and One latest Record from previous dates (i.e from 7th sep if there exist the record on the date ...or 6th or 5th ...) Can anybody help me how to do it.Azhar RahiSoftware EngineerEye4tech Pvt Ltd,Lahore Pakistan |
|
eyechart
Master Smack Fu Yak Hacker
3575 Posts |
Posted - 2006-09-08 : 03:46:12
|
this sounds suspicially school related, so I will just give you some clues how to do this. Plus it is late for me...anyway, look at using the TOP keyword with ORDER BY DESC in your SELECT statement. If you need more help, just check books online and look at TOP..-ec |
 |
|
mrsaif
Starting Member
43 Posts |
Posted - 2006-09-08 : 03:48:26
|
select top 3 NewsID, Headline,Detail,Date from newsManagement order by date descMuhammad Saifullah |
 |
|
eyechart
Master Smack Fu Yak Hacker
3575 Posts |
Posted - 2006-09-08 : 03:57:56
|
quote: Originally posted by eyechart this sounds suspicially school related, so I will just give you some clues how to do this. Plus it is late for me...anyway, look at using the TOP keyword with ORDER BY DESC in your SELECT statement. If you need more help, just check books online and look at TOP..
or, you could just wait for mrsaif to come along and post the answer..-ec |
 |
|
OBINNA_EKE
Posting Yak Master
234 Posts |
Posted - 2006-09-08 : 04:24:28
|
Are you happy with the answer ? azharrahiIf it is that easy, everybody will be doing it |
 |
|
azharrahi
Starting Member
44 Posts |
Posted - 2006-09-08 : 07:27:51
|
yes I have always been happy Obinna. ;) well my problem is solved by the query of eyechart and mr saif .. well both queries are same :D.... actually it was very simple solution and when i read the query i felt shameful how easy the solution was and why i was annoying :D ...well thanks all of youAzhar RahiSoftware EngineerEye4tech Pvt Ltd,Lahore Pakistan |
 |
|
|
|
|
|
|