Solved

sql query with 2 Max parameters

Posted on 2014-03-22
4
476 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
[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
4 Comments
 
LVL 42

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 70

Expert Comment

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

Expert Comment

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

Featured Post

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

As technology users and professionals, we’re always learning. Our universal interest in advancing our knowledge of the trade is unmatched by most industries. It’s a curiosity that makes sense, given the climate of change. Within that, there lies a…
Recently, Microsoft released a best-practice guide for securing Active Directory. It's a whopping 300+ pages long. Those of us tasked with securing our company’s databases and systems would, ideally, have time to devote to learning the ins and outs…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

738 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