Solved

Query to get the soonest date out of a few records

Posted on 2016-09-28
2
31 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
Comment Utility
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
Comment Utility
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

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…
I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

772 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

11 Experts available now in Live!

Get 1:1 Help Now