How to get the maximum index of the table, if there is such a function?

Category: MS-SQL Server -> Applications Author: kk0000000 Date: 2007-07-15 19:33:00
 
kk0000000
2007-07-15 19:33:00
I want each query are from the most recent 1000 record query, so I want to know my maximum aggregate index ID, and then between the maximum and (max - 1000) I ask whether the database directly know what function the maximum table ID?
the same time, ask a risky question: I want to date as my aggregate function, the ID as a non-aggregate functions, okay? Because each ID is different, and there are many of the same date. Besides, each query, always be sure to check the date, but will not let you check the ID.

Also, I would like to ask, if I use the getdate () function to know the current date, I want to query between the current date and 30 days prior to the record, then how do I write the first 30 days ago Date it?
Thank you! ! !
tangbai11
2007-07-15 19:50:06
1; largest IDselect max (id) as id
2.30 days following dates
SELECT DATEADD (day, 30, the time field) AS 30 days after the date from table
wjshu1971
2007-07-15 20:03:13
select * from table where DATEDIFF (d, date fields, getdate ( )) <= 30
yccc2009
2007-07-15 20:20:00
can put the date as a polymerization index that provides query speed