Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Query to get the soonest date out of a few records

Posted on 2016-09-28
2
Medium Priority
?
56 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 53

Accepted Solution

by:
Ryan Chong earned 2000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

604 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