views:

16

answers:

1

What I need is query that show :

How many times value in field is Appearance and how many Percentage is from the total.

What I have until now is :

SELECT field, COUNT(field)
FROM table 
GROUP BY field;

That show me result of how many time every value is Appearance.

How can I get also the Appearance Percentage in one query ?

I try to get the total of records like :

SELECT field, COUNT(field) as A , COUNT(primaryId) as B  ...

But this show the same value in A and B !

A: 

i found this but is there a better option ?

SELECT field, COUNT(field) , 
COUNT(field) / (SELECT COUNT(*) FROM table) AS percentage
FROM table 
GROUP BY field;
Haim Evgi