Hi there,
I've got a peculiar problem with the SUM function.
I have the following data:
[ul]
[li]a list of surfaces[/li]
[li]a status for each surface[/li]
[li]a size for each surface[/li]
[/ul]
I know that there are three possible stati for each surface.
No I would like to have a report that contains the following information:
"Surfacetitle" "Status1 Sum" "Status2 Sum" "Status3 Sum" "Total Sum"
For example:
That means the Status1 Sum column should contain the total sum of surfaces with the specified title having status 1 and so on. The last column contains the total sum of all stati.
Up to now I have the following SELECT statement:
That's the first and the last column. But what kind of function do I use for the middle columns?
NOTE: Because of some conditions at work I cannot use subqueries (would be rather easy then). It has to be included in this one SELECT statement.
thx alot for your help
Feanaro
I've got a peculiar problem with the SUM function.
I have the following data:
[ul]
[li]a list of surfaces[/li]
[li]a status for each surface[/li]
[li]a size for each surface[/li]
[/ul]
I know that there are three possible stati for each surface.
No I would like to have a report that contains the following information:
"Surfacetitle" "Status1 Sum" "Status2 Sum" "Status3 Sum" "Total Sum"
For example:
Code:
Production_234 45m² 5m² 12m² 62m²
Acquisition_12 12m² 0 33m² 45m²
That means the Status1 Sum column should contain the total sum of surfaces with the specified title having status 1 and so on. The last column contains the total sum of all stati.
Up to now I have the following SELECT statement:
Code:
SELECT Surfaces.surface, SUM(Surfaces.size)
FROM Surfaces, Stati
WHERE Surfaces.Status = Stati.Status
GROUP BY Surfaces.surface
That's the first and the last column. But what kind of function do I use for the middle columns?
NOTE: Because of some conditions at work I cannot use subqueries (would be rather easy then). It has to be included in this one SELECT statement.
thx alot for your help
Feanaro