quietstormtw
Programmer
Hi all,
I am in desparate need of some assistance with the following SQL statement. What I am attempting to accomplish is to have the Name, ID & Company listed, with the case count listed for each Company.
SELECT
a.name,
a.id,
b.company
(SELECT count(c.cases)
FROM table3 c
WHERE c.id = a.id) Count
FROM
table1 a,
table2 b
WHERE
a.id = b.id
Gives me this as a result:
Name ID Company Case Count
Ronnie 1470 LBL 15
Ronnie 1470 JHM 15
Ronnie 1470 FCL 15
Bobby 2585 LBL 12
Bobby 2585 MAN 12
Bobby 2585 AET 12
What I would like to have is this:
Name ID Company Case Count
Ronnie 1470 LBL 5
Ronnie 1470 JHM 3
Ronnie 1470 FCL 7
Bobby 2585 LBL 4
Bobby 2585 MAN 2
Bobby 2585 AET 6
Again, any assistance in this would be a life saver. Thanks in advance.
I am in desparate need of some assistance with the following SQL statement. What I am attempting to accomplish is to have the Name, ID & Company listed, with the case count listed for each Company.
SELECT
a.name,
a.id,
b.company
(SELECT count(c.cases)
FROM table3 c
WHERE c.id = a.id) Count
FROM
table1 a,
table2 b
WHERE
a.id = b.id
Gives me this as a result:
Name ID Company Case Count
Ronnie 1470 LBL 15
Ronnie 1470 JHM 15
Ronnie 1470 FCL 15
Bobby 2585 LBL 12
Bobby 2585 MAN 12
Bobby 2585 AET 12
What I would like to have is this:
Name ID Company Case Count
Ronnie 1470 LBL 5
Ronnie 1470 JHM 3
Ronnie 1470 FCL 7
Bobby 2585 LBL 4
Bobby 2585 MAN 2
Bobby 2585 AET 6
Again, any assistance in this would be a life saver. Thanks in advance.