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)
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top