SQL join - TechRepublic
Question
August 20, 2011 at 04:05 PM
skatula

SQL join

by skatula . Updated 14 years, 10 months ago

Please how can I combine these select statements using a join and then insert the result into a new table.

SELECT
team, SUM(operations) as Operations_Completed
from Table1
where team in (‘bristol’, ‘leeds’, ‘newcastle’,’north west’)
group by team

SELECT

team,
SUM(sales) as Packsales,
COUNT(*) as contacts,
COUNT(CASE WHEN brandtype = ‘SOB’ THEN brandtype ELSE NULL END) as EffectiveContacts

from Table2
where team not in (‘MANCHESTER GREATER’,’MANCHESTER CITY’)
group by team

This discussion is locked

All Comments