Reputation: 125
i have one table, let's call it 'TBL'.
i have one column that have only 3 values available.(let's say 'AAA', 'BBB', 'CCC')
the values can return multiple times.
for example:
TBL
---
Column1
-------
AAA
AAA
BBB
CCC
BBB
CCC
BBB
CCC
AAA
i want to create a table result that looks like this:
TBL-RESULT
----------
AAA+BBB 60%
CCC 40%
i want to show AAA and BBB in one result and there precentage from all values in one line, and CCC in a second line as well.
the big problem is also that i need to do so in sql of ACCESS (2007).
can someone help me?
thank you, gady m
Upvotes: 2
Views: 580
Reputation: 16003
Assume table is called MyTable
and column is MyColumn
select IIF(MyColumn<>'CCC', 'AAA+BBB', 'CCC'),
100*count(MyColumn='CCC')/(select count(*) from MyTable) from MyTable
group by MyColumn='CCC'
Upvotes: 1