Solved

Query to get the soonest date out of a few records

Posted on 2016-09-28
2
41 Views
Last Modified: 2016-09-28
Hi there, I have a query that I want to modify so I can get the soonest date from a few different records

Set TicketDiscount=oConn.Execute("SELECT * FROM ticket_discount WHERE ticket_ID="&Request.QueryString("ticket"))

Open in new window


The records have dates of expiry, eg
ticket 1 exp=2/12/16
ticket 2 exp=8/5/1=7

What I want to do is grab the ticket that the expiry is soonest, how would I modify my query to do that?

Cheers all
0
Comment
Question by:Graeme
2 Comments
 
LVL 49

Accepted Solution

by:
Ryan Chong earned 500 total points
ID: 41819316
hi,
do you mean this?

Set TicketDiscount=oConn.Execute("SELECT top 1 * FROM ticket_discount  order by Expiry_Date desc")

Open in new window

0
 

Author Closing Comment

by:Graeme
ID: 41819331
With a bit of playing here it is! :)

Set TicketDiscount=oConn.Execute("SELECT TOP 1 * FROM ticket_discount WHERE ticket_ID="&Request.QueryString("ticket")&" ORDER BY ticket_exp")
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now