How can I use count(*) with out sorting ? [message #18425] |
Wed, 30 January 2002 18:38  |
Samuel
Messages: 17 Registered: September 2000
|
Junior Member |
|
|
How can I count aggregate value on a column with out sorting. There are two possible values for a column
and if I use a count(*) and group by I will end up
with results like
0 56
1 79
however if count(*) is used with out sorting, the result will look like the following, which is the desired outcome
0 3
1 5
0 3
...
|
|
|
|
Re: How can I use count(*) with out sorting ? [message #18456 is a reply to message #18436] |
Thu, 31 January 2002 08:43  |
Samuel
Messages: 17 Registered: September 2000
|
Junior Member |
|
|
Thanks,
Here is an example
TABLE TASKS
(
resultid number,
taskid number,
success number, /* 0 or 1 */
locationid number
)
Sample Date Looks like this
RESULTID TASKID SUCCESS LOCATIONID
1 4182 1 53
2 4182 1 52
3 4182 0 52
4 4182 0 53
5 4182 1 82
6 4182 1 53
7 4182 1 45
The desired output counting on success and grouping by taskid should look like the following
TASKID COUNT(success)
1 2 /* first two rows */
0 2 /* next two rows */
1 3 /* last three rows */
|
|
|