Little_Man22
Registered User.
- Local time
- Today, 03:13
- Joined
- Jun 23, 2001
- Messages
- 118
Hi All,
If someone could give me a hand with this SQL problem, I'd be most appreciative.
The following code works, but it gives me totals for the company instead of the total per club name (cName) which is what I want. I need to know how to make it do totals by club name. Any ideas?
SELECT C.cName AS Club, cost.A AS Total_Cost_of_Equipment, useCharge.B AS Total_Revenue, payments.C AS Total_Payments, Visits.D AS Total_Visits
FROM ( SELECT SUM(E.cost) A
FROM Equipment E ) AS cost,
( SELECT SUM(U.useCharge) B
FROM Uses U ) AS useCharge,
( SELECT SUM(P.amount) C
FROM Payment P, Member M, Club C
WHERE P.SIN = M.SIN AND M.homeClub = C.cName ) AS Payments,
( SELECT COUNT(V.SIN) D
FROM Visit V ) AS Visits,
Club C
/* Need to GROUP BY cName */
OUTPUT:
Club Total_Cost_of_Equipment Total_Revenue Total_Payments Total_Visits
Bluebell 609363.0 629.0 337.0 149
Daffodil 609363.0 629.0 337.0 149
Lupin 609363.0 629.0 337.0 149
Marigold 609363.0 629.0 337.0 149
Poppy 609363.0 629.0 337.0 149
Primrose 609363.0 629.0 337.0 149
If someone could give me a hand with this SQL problem, I'd be most appreciative.
The following code works, but it gives me totals for the company instead of the total per club name (cName) which is what I want. I need to know how to make it do totals by club name. Any ideas?
SELECT C.cName AS Club, cost.A AS Total_Cost_of_Equipment, useCharge.B AS Total_Revenue, payments.C AS Total_Payments, Visits.D AS Total_Visits
FROM ( SELECT SUM(E.cost) A
FROM Equipment E ) AS cost,
( SELECT SUM(U.useCharge) B
FROM Uses U ) AS useCharge,
( SELECT SUM(P.amount) C
FROM Payment P, Member M, Club C
WHERE P.SIN = M.SIN AND M.homeClub = C.cName ) AS Payments,
( SELECT COUNT(V.SIN) D
FROM Visit V ) AS Visits,
Club C
/* Need to GROUP BY cName */
OUTPUT:
Club Total_Cost_of_Equipment Total_Revenue Total_Payments Total_Visits
Bluebell 609363.0 629.0 337.0 149
Daffodil 609363.0 629.0 337.0 149
Lupin 609363.0 629.0 337.0 149
Marigold 609363.0 629.0 337.0 149
Poppy 609363.0 629.0 337.0 149
Primrose 609363.0 629.0 337.0 149
Last edited: