Domanda

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

È stato utile?

Soluzione

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)
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top