E
elvio.serrao
Hi All,
I would like to ask for your assistance with merging two queries into
one to achieve a desired outcome. The first query counts the total
occurrences for each ANI. The second query counts the total for a
specific condition of each ANI.
As an example the raw data is:
Date Time FinalStatus SysID
DNIS ANI
10/05/2007 11:26:33 AM 30 7015
80675901 255328862
10/05/2007 11:26:26 AM 30 7025
85867801 255328862
10/05/2007 11:26:23 AM 30 7025
85867001 255632043
10/05/2007 11:26:24 AM 30 7025
85867801 338841575
10/05/2007 11:26:35 AM 37 7025
85867001 394857311
10/05/2007 11:26:35 AM 30 7015
80675901 438162610
10/05/2007 11:26:30 AM 30 7015
80675401 632753715
10/05/2007 11:26:36 AM 30 7025
85867001 632753715
10/05/2007 11:26:33 AM 30 7025
85867801 632753715
10/05/2007 11:26:28 AM 37 7025
85867801 832733914
10/05/2007 11:26:35 AM 30 7025
85867001 932533083
10/05/2007 11:26:28 AM 30 7015
80675401 932832500
10/05/2007 11:26:34 AM 30 7015
80675901 933453048
10/05/2007 11:26:34 AM 30 7015
80675901 935117655
10/05/2007 11:26:23 AM 30 7015
80675901 941625218
10/05/2007 11:26:25 AM 30 7025
85867801 941625218
10/05/2007 11:26:25 AM 37 7025
85867801 941625218
10/05/2007 11:26:31 AM 30 7025
85867801 941625218
10/05/2007 11:26:30 AM 30 7025
85867801 945769483
10/05/2007 11:26:33 AM 30 7025
85867001 947765881
10/05/2007 11:26:30 AM 30 7015
80675401 955174778
10/05/2007 11:26:28 AM 30 7015
80675901 955791158
10/05/2007 11:26:26 AM 30 7025
85867001 955791158
10/05/2007 11:26:32 AM 30 7025
85867801 955791158
10/05/2007 11:26:34 AM 37 7025
85867001 955791158
The expected outcome will be:
ANI TotalCalls FailedCalls
255328862 2 0
255632043 1 0
338841575 1 0
394857311 1 1
438162610 1 0
632753715 3 0
832733914 1 1
932533083 1 0
932832500 1 0
933453048 1 0
935117655 1 0
941625218 4 1
945769483 1 0
947765881 1 0
955174778 1 0
955791158 4 1
The two queries that can acheive the required data results are:
SELECT LoggedCalls.ANI, Count(*) AS TotalCalls
FROM LoggedCalls
WHERE Right(DNIS,2)="01"
GROUP BY LoggedCalls.ANI
ORDER BY Count(*) DESC;
SELECT LoggedCalls.ANI, COUNT(*) AS FailedCalls
FROM LoggedCalls
WHERE LoggedCalls.FinalStatus<>'30' And Right(LoggedCalls.DNIS,
2)="01"
GROUP BY LoggedCalls.ANI
ORDER BY COUNT(*) DESC;
I don't know how to combine the two queries to acheive the expected
outcome above. Any help is greatly appreciated.
Thank you.
I would like to ask for your assistance with merging two queries into
one to achieve a desired outcome. The first query counts the total
occurrences for each ANI. The second query counts the total for a
specific condition of each ANI.
As an example the raw data is:
Date Time FinalStatus SysID
DNIS ANI
10/05/2007 11:26:33 AM 30 7015
80675901 255328862
10/05/2007 11:26:26 AM 30 7025
85867801 255328862
10/05/2007 11:26:23 AM 30 7025
85867001 255632043
10/05/2007 11:26:24 AM 30 7025
85867801 338841575
10/05/2007 11:26:35 AM 37 7025
85867001 394857311
10/05/2007 11:26:35 AM 30 7015
80675901 438162610
10/05/2007 11:26:30 AM 30 7015
80675401 632753715
10/05/2007 11:26:36 AM 30 7025
85867001 632753715
10/05/2007 11:26:33 AM 30 7025
85867801 632753715
10/05/2007 11:26:28 AM 37 7025
85867801 832733914
10/05/2007 11:26:35 AM 30 7025
85867001 932533083
10/05/2007 11:26:28 AM 30 7015
80675401 932832500
10/05/2007 11:26:34 AM 30 7015
80675901 933453048
10/05/2007 11:26:34 AM 30 7015
80675901 935117655
10/05/2007 11:26:23 AM 30 7015
80675901 941625218
10/05/2007 11:26:25 AM 30 7025
85867801 941625218
10/05/2007 11:26:25 AM 37 7025
85867801 941625218
10/05/2007 11:26:31 AM 30 7025
85867801 941625218
10/05/2007 11:26:30 AM 30 7025
85867801 945769483
10/05/2007 11:26:33 AM 30 7025
85867001 947765881
10/05/2007 11:26:30 AM 30 7015
80675401 955174778
10/05/2007 11:26:28 AM 30 7015
80675901 955791158
10/05/2007 11:26:26 AM 30 7025
85867001 955791158
10/05/2007 11:26:32 AM 30 7025
85867801 955791158
10/05/2007 11:26:34 AM 37 7025
85867001 955791158
The expected outcome will be:
ANI TotalCalls FailedCalls
255328862 2 0
255632043 1 0
338841575 1 0
394857311 1 1
438162610 1 0
632753715 3 0
832733914 1 1
932533083 1 0
932832500 1 0
933453048 1 0
935117655 1 0
941625218 4 1
945769483 1 0
947765881 1 0
955174778 1 0
955791158 4 1
The two queries that can acheive the required data results are:
SELECT LoggedCalls.ANI, Count(*) AS TotalCalls
FROM LoggedCalls
WHERE Right(DNIS,2)="01"
GROUP BY LoggedCalls.ANI
ORDER BY Count(*) DESC;
SELECT LoggedCalls.ANI, COUNT(*) AS FailedCalls
FROM LoggedCalls
WHERE LoggedCalls.FinalStatus<>'30' And Right(LoggedCalls.DNIS,
2)="01"
GROUP BY LoggedCalls.ANI
ORDER BY COUNT(*) DESC;
I don't know how to combine the two queries to acheive the expected
outcome above. Any help is greatly appreciated.
Thank you.