June 19, 2006 at 1:03 am
Dear,
I have written query to select top3 records, as below
select top 3 c_name,c_add from customers
it is working ok.
but when i insert new records even though it doesnt fetch new inserted records,
I want top 3 records which are inserted last.
is there any query like?
select last 3 c_name,c_add from customer
i want only 3 records which are inserted last.
Please help me
regards,
June 19, 2006 at 1:18 am
Hallo please test this i have found times ago ,
SELECT TOP 3
FELDA, FELDB, ...
FROM Datenquelle
ORDER BY ID_FELD DESC
Greetings Thomas
June 19, 2006 at 6:27 am
Do you have an identity column, a time stamp column or a column that shows date entered (default getdate())? If not, there's no way to get the latest 3 rows. SQL doesn't keep any record of when a row was entered.
If you have an identity or a date entereed then you can get top 3 order by <column> desc where <column> is your identity or date column
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply