michaela18
Technical User
I want to learn how to do nested selects, I am confused by the "(" and the commas. How do I combine all these selects into 1 so it shows on 1 result panel?
Code:
Select date, Count (*) as '1_year'
from callrecord
where date >= '20100201'
and date <= '20100224'
and State in ('Process', 'Great')
and Fam= 'N'
and CodeIN ('100', '101', '105', '111', '113', '102','115', '117','120','121', '123', '124')
and Plan <> ''
and Terms in ('0', '1')
group by date
Select date, Count (*) as '2_year'
from callrecord
where date >= '20100201'
and date <= '20100224'
and State in ('Process', 'Great')
and Fam= 'N'
and CodeIN ('100', '101', '105', '111', '113', '102','115', '117','120','121', '123', '124')
and Terms = '2'
and PhoneModel <> ''
group by date
Select date, Count (*) as 'US'
from callrecord
where date >= '20100201'
and date <= '20100224'
and State in ('Process', 'Great')
and Fam= 'N'
and CodeIN ('100', '101', '105', '111', '113', '102','115', '117','120','121', '123', '124')
and Terms = '2'
and PhoneModel = ''
and left(MobilePhoneNumber,3) in ('201', '551', '609', '732', '848', '856', '862', '908', '973', '215', '267', '412', '484', '570', '610', '717', '724', '814')
group by date
Select date, Count (*) as 'AVS'
from callrecord
where date >= '20100201'
and date <= '20100224'
and State in ('Process', 'Great')
and Fam= 'N'
and CodeIN ('100', '101', '105', '111', '113', '102','115', '117','120','121', '123', '124')
and Terms = '2'
and PhoneModel = ''
and left(MobilePhoneNumber,3) not in ('201', '551', '609', '732', '848', '856', '862', '908', '973', '215', '267', '412', '484', '570', '610', '717', '724', '814')
and IVRComplete = 'Y'
group by date
Select date, Count (*) as 'Total'
from callrecord
where date >= '20100201'
and date <= '20100224'
and State in ('Process', 'Great')
and Fam= 'N'
and CodeIN ('100', '101', '105', '111', '113', '102','115', '117','120','121', '123', '124')
and Terms = '2'
group by date