konakzizu
konakzizu

Reputation: 39

I need to query a result from query in SQL

i have this query :

SELECT object, date, MAX(min) as max FROM total GROUP BY obect, date

and gives me this table result:

object date max
2 2021-09-09 660
2 2021-09-11 555
3 2021-09-09 555
4 2021-09-09 630
5 2021-09-10 555

now i need to query this result with this query:

SELECT sum(max), object, FORM total GROUP BY object

Upvotes: 0

Views: 35

Answers (1)

nbk
nbk

Reputation: 49375

Use the first Select as basis for the second

SELECT sum(max), object
FROM
(SELECT object, date, MAX(min) as max FROM total GROUP BY obect, date) t1
GROUP By object

Upvotes: 2

Related Questions