|
-
Feb 21st, 2004, 03:49 PM
#1
Thread Starter
New Member
SQL string question
I nearly have my problem figured out, but have one question…
My SQL statement reads as follows:
sql = "SELECT * FROM upcoming_dvd order by stdate,title asc"
What I want is for it to display the earliest Street Date (stdate) in the DB and only that date and then order those by title (so if the earliest stdate is 2/17/2004, then display all those titles that have that street date). But I’m having trouble doing that. Any ideas as to what my SQL statement would be?
So I guess I want to select a distinct date (the earliest in the DB) and only display that date and the titles associated with it.
Any ideas?
-
Feb 21st, 2004, 04:22 PM
#2
PowerPoster
Maybe this work?
Code:
sql = "SELECT * FROM upcoming_dvd where stdate in (select top 1 stdate from upcoming_dvd order by stdate) order by stdate,title asc
' I am not sure
if this wont work, then try this
sql = "SELECT * FROM upcoming_dvd where stdate in (select top 1 stdate from upcoming_dvd order by stdate desc) order by stdate,title asc
-
Feb 21st, 2004, 04:25 PM
#3
For an access database...
sql = "SELECT TOP 1 * FROM upcoming_dvd order by stdate,title asc"
... returns first record based on order.
-
Feb 21st, 2004, 06:06 PM
#4
Thread Starter
New Member
That worked, all I had to do was change the desc to asc. But other than that, it worked perfectly.
Thanks so much!
-
Mar 4th, 2004, 03:44 PM
#5
Lively Member
Sorry to interupt, but once you create the stringed sql statement, how do you get it to execute?
I must add to this. I'm coding in a stored procedure. So this is in Transact-SQL.
Thanx
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|