简体   繁体   中英

MIN and MAX Oracle 10g

I have a table with a sales column and date of that sales column, and I want to select the min and max and the date of this min and max for response a single max with its date and single min with its date, in Oracle, but I don't know how do it, any idea?

Thanks

From your Explanation it looks like you need something like below:

1) SELECT Sales , date FROM TABLE_NAME WHERE Sales = ( SELECT MIN(Sales) FROM TABLE_NAME)

2) SELECT Sales , date FROM TABLE_NAME WHERE Sales = ( SELECT MAX(Sales) FROM TABLE_NAME)

In single Query

    SELECT Sales , date FROM TABLE_NAME WHERE Sales = ( SELECT MIN(Sales) FROM TABLE_NAME)

    UNION 

    SELECT Sales , date FROM TABLE_NAME WHERE Sales = ( SELECT MAX(Sales) FROM

 TABLE_NAME)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM