| Needed SQL Query to count fields
|
mamylo

msg:4198042 | 10:09 pm on Sep 7, 2010 (gmt 0) | Hi I have a table named test with two fields: ID and value And I insert these records:
ID value 1 a 2 b 3 a 4 a 5 c 6 b 7 a 8 d
I want to write an SQL query to get this result:
a b c d 4 2 1 1 How can I get this result? Note: I know I can use COUNT with GROUP BY, but I want to get this data with only 1 fetching. Thanks in advance
|
topr8

msg:4198290 | 7:45 am on Sep 8, 2010 (gmt 0) | SELECT COUNT(*) as counter,value FROM test GROUP BY value ORDER BY value;
|
LifeinAsia

msg:4198532 | 3:37 pm on Sep 8, 2010 (gmt 0) | The OP wants the results displayed as: a b c d 4 2 1 1 Not as: a 4 b 2 c 1 d 1 What DB are you using? Certain DBs may have a proprietary function to do something like that.
|
|
|