views:

94

answers:

1

hello all,
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

+1  A: 

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'
hawbsl
Did you mean IIF or IF?
Frank Shearar
hy again, your answer is working grate! but it's seems that i miss something. in that same table i have also empty values that i want to ignore them it's looks something like this: MyTable ------- Column1 ------- AAA AAA BBB CCC BBB CCC BBB CCC AAA how can i adjust your answer to the new situation? thank you again, gady m
gadym
in my last comment the example doesnt show properly, there are empty rows between some values...
gadym
@Frank IIF ... in Access SQL
hawbsl
@gadym are your blanks empty strings or nulls?
hawbsl