Reputation: 313
I want a+b to get to C. How do I combine A and B ?
Thanks :)
Table A
SELECT init, MIN(p.aarstal) AS startyear
FROM placering p
GROUP BY init
ORDER BY startyear
Table B
SELECT init, MAX(p.aarstal) AS endyear
FROM placering p
GROUP BY init
ORDER BY endyear
Upvotes: 1
Views: 58
Reputation: 136
They're the same table, so you just need to combine the logic of both queries. See below for an example.
SELECT
p.init,
min(p.aarstal) as startyear,
max(p.aarstal) as endyear
FROM placering p
GROUP BY init
ORDER BY startyear, endyear
Upvotes: 1
Reputation: 222402
Are you just looking for this ?
SELECT init, min(p.aarstal) as startyear, max(p.aarstal) as endyear
FROM placering p
GROUP BY init
ORDER BY startyear, endyear
Upvotes: 1
Reputation: 1269503
You just select both expressions in a single select
:
select init, min(p.aarstal) as startyear, max(p.aarstal) as endyear
from placering p
group BY init
order by startyear
Upvotes: 1