Computing.Net > Forums > Programming > Easy SQL question

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Easy SQL question

Reply to Message Icon

Name: Drew
Date: November 18, 2002 at 07:01:03 Pacific
OS: Win2K
CPU/Ram: 1Gig
Comment:

I should know how to do this, but I'm looking to grab all records from a table that have a date that is greater then or equal to the max date in the table - 2. Maybe I'm just tired and can't think, please help!



Sponsored Link
Ads by Google

Response Number 1
Name: Don Arnett
Date: November 18, 2002 at 08:54:43 Pacific
Reply:

I think that this will take a nested query:

I'm not at a place where I can try this, and it'll probably be different between different DBSs, but it should be something like this:


select * from table
where somedate >= (select max(somedate) -2 from table)


-check that max() is a valid function and works on dates
-check if just saying -2 is the correct way to back up two days

But the idea is that the nested query (select max......) returns one value that is used in the comparison in the where clause of the main query.


0
Reply to Message Icon

Related Posts

See More


C structures c++ program cose



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Easy SQL question

SQL question papers www.computing.net/answers/programming/sql-question-papers/1638.html

easy VB6 questions www.computing.net/answers/programming/easy-vb6-questions/5807.html

Easy Batch question www.computing.net/answers/programming/easy-batch-question/12061.html