Link to home
Create AccountLog in
Avatar of Allen Pitts
Allen PittsFlag for United States of America

asked on

Date and dollar comparison

Good afternoon expert,

Users are inputting a date and a dollar amount on the same row.

The most recent date with a dollar amount greater than $150,000 is needed.

I can get the most recent date
with  

Select MIN(SH_MR_Dollar_Date)
from
SH_MR_Dollar_Threshold

but to get the amount greater than $150K


Select Dollar_Amount
from
SH_MR_Dollar_Threshold
where Dollar_Amount > 150000
AND MIN(SH_MR_Dollar_Date)

I get ' Group function not allowed here'

How can I get the most recent date with theamount over $150k?

Thanks.

Allen in Dallas
Avatar of Sean Stuber
Sean Stuber

select * from
(select SH_MR_Dollar_Date, dollar_amount
from
SH_MR_Dollar_Threshold
where dollar_amount > 150000
order by sh_mr_dollar_date)
where rownum = 1
ASKER CERTIFIED SOLUTION
Avatar of Sean Stuber
Sean Stuber

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account