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
Solved

sql query with 2 Max parameters

Posted on 2014-03-22
4
472 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 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 69

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Select single row of data for each ID in Select Statement 7 26
SQL Log size 3 17
SQL R 21 25
Testing for Null in Stored Proc Return Value 5 11
Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
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.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

839 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