I'm selecting the same data from 2 different tables and dumping the results in one temp table. In the temp table, how can I differientiate the data between the tables? For instance, how can I count all records from each set of data and tell know the counts for each table? For an example:
SELECT
INTO
#Temp1
FROM
(SELECTCOUNT(phonenumber)AS VBPSR1 FROM TableA
WHERE
length> 2
AND
callingmode <> 0--Non Dialer Call
and
iscontact=1
AND
reason='NotAvailable'
AND
finishcode ='NotAvailable'
AND
calltime >='1/1/13'
AND
calltime <'9/19/13'
GROUP
UNION
SELECTCOUNT(phonenumber)AS VBPSR2 FROMTableB
WHERE
length> 2
AND
callingmode <> 0--Non Dialer Call
and
iscontact=1
AND
reason='NotAvailable'
AND
finishcode ='NotAvailable'
AND
calltime >='1/1/13'
AND
calltime <'9/19/13'
GROUP
BY name,RIGHT(CONVERT(VARCHAR(10), calltime, 103), 7)) AS FIRSTCOUNT