Solved

sql query with 2 Max parameters

Posted on 2014-03-22
4
467 Views
Last Modified: 2014-03-23
Hi Experts

Using an sql query I want to get a particular column value for a row that has MAX values in 2 other columns, something like:

SELECT FloatAmount, MAX(CountDate), MAX(CountDateNumber)
FROM Count


Has anyone got any idea how to do this?
0
Comment
Question by:dizzycat
  • 2
4 Comments
 
LVL 41

Accepted Solution

by:
pcelba earned 500 total points
ID: 39947733
If these two max values are in different rows then you have no solution...
If you have duplicate max values then you have many solutions...

SELECT FloatAmount, CountDate, CountDateNumber FROM Count
WHERE CountDate = (SELECT MAX(CountDate) FROM Count)
  AND CountDateNumber = (SELECT MAX(CountDateNumber) FROM Count)

So you have to better specify what is your goal.
0
 

Author Closing Comment

by:dizzycat
ID: 39947741
That's great, thanks.
0
 
LVL 68

Expert Comment

by:Qlemo
ID: 39947762
You should have waited for better suggestions ;-).
0
 
LVL 41

Expert Comment

by:pcelba
ID: 39948715
You may still post them :-)
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Never store passwords in plain text or just their hash: it seems a no-brainier, but there are still plenty of people doing that. I present the why and how on this subject, offering my own real life solution that you can implement right away, bringin…
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Viewers will learn how the fundamental information of how to create a table.

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

11 Experts available now in Live!

Get 1:1 Help Now