?
Solved

Query to get the soonest date out of a few records

Posted on 2016-09-28
2
Medium Priority
?
54 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

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

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 informatio…
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

800 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