Home » SQL & PL/SQL » SQL & PL/SQL » How can I use count(*) with out sorting ?
How can I use count(*) with out sorting ? [message #18425] Wed, 30 January 2002 18:38 Go to next message
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 #18436 is a reply to message #18425] Thu, 31 January 2002 00:59 Go to previous messageGo to next message
pratap kumar tripathy
Messages: 660
Registered: January 2002
Senior Member
hi,

your problem is not clear. can u give an example.
give table structure and few data and the output u want to see.

cheers
pratap
Re: How can I use count(*) with out sorting ? [message #18456 is a reply to message #18436] Thu, 31 January 2002 08:43 Go to previous message
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 */
Previous Topic: Help with Logic !!!!!!!!
Next Topic: Using variables for accessing tables in pl/sql
Goto Forum:
  


Current Time: Fri Mar 29 07:00:47 CDT 2024