Hello my fellow colleagues from CodeProject!
I will be brief, and cut to the point:
I work on Windows XP, in C++, using ADO to access an MS Access 2007 database.
I have a table in MS Access 2007 which contains 2 columns of interest titled as TypeOfObject and InstaledPower.
The actual table looks something like this:
| TypeOfObject | InstaledPower |
| Type1 | 1000 |
| Type2 | 2000 |
| Type3 | 450 |
| Type4 | 800 |
| Type1 | 800 |
I need a query that displays TypeOfObject and sum( InstaledPower ) for that type, in this manner:
If value of TypeOfObject is Type1 or Type2, than show it's value in table unchanged, else mark it as OtherTypes. The result should be like this:
| TypeOfObject | SUM(InstaledPower) |
| Type1 | 1800 | <
| Type2 | 2000 | <
| OtherTypes | 1250 | <
I have tried with this query:
SELECT TypeOfObject ,
SUM( InstaledPower ) as [SUM(InstaledPower)]
FROM MyTable
group by TypeOfObject ;
but I get this:
| TypeOfObject | SUM(InstaledPower) |
| Type1 | 1800 | <
| Type2 | 2000 |
| Type3 | 450 | <
| Type4 | 800 | <
By searching through Internet, I have come to the conclusion that this problem might be solved with pivot tables, but I do not know how to use them properly.
If that is the case, if pivot table can solve this, some links would be greatly appreciated.
If there is anything else that I can do to help, ask and I will gladly do it.
Thanks to everybody who tries to help.