Pergunta

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

Foi útil?

Solução

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)
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top