1

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

enter image description here

enter image description here

3 Answers 3

1

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
Sign up to request clarification or add additional context in comments.

Comments

1

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

Comments

1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.