Hi,
I am trying to create the following query in access (using SQL or otherwise).
I have a table which contains (omitting irrelevant ones) 3 fields, say A, B and C. A is something I want to group by, B is a character which is either "X" or "Y" and C is a value I want to display the sum of for each mode in A,
e.g.
SELECT A, Sum(C) FROM table GROUP BY A ORDER BY A;
giving me two columns in the resulting query.
What I really would like would be 3 columns
A,CX,CY where CX is the Sum of all C's within A where B="X" and CY is the equivalent where B="Y" (i.e. for each resulting row C=CX+CY).
How can I tell SQL/Access to perform this split, ideally within an SQL statement since I have similar issues in other queries and dont want to end up creating numerous other queries/tables.
Many thanks in advance
I am trying to create the following query in access (using SQL or otherwise).
I have a table which contains (omitting irrelevant ones) 3 fields, say A, B and C. A is something I want to group by, B is a character which is either "X" or "Y" and C is a value I want to display the sum of for each mode in A,
e.g.
SELECT A, Sum(C) FROM table GROUP BY A ORDER BY A;
giving me two columns in the resulting query.
What I really would like would be 3 columns
A,CX,CY where CX is the Sum of all C's within A where B="X" and CY is the equivalent where B="Y" (i.e. for each resulting row C=CX+CY).
How can I tell SQL/Access to perform this split, ideally within an SQL statement since I have similar issues in other queries and dont want to end up creating numerous other queries/tables.
Many thanks in advance