Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 more efficient query with grouping and counting

Author  Topic 

onderaydogan
Starting Member

6 Posts

Posted - 2001-08-07 : 07:07:21
i need a query to prepare a report for the production people at our factory site.

database table is like this :

stop_code stop_def duration continue
--------- -------- -------- --------
0122 fuse trip 15
0123 breaker trip 30
0123 breaker trip 12 X
0123 breaker trip 50
0122 fuse trip 10

my report should give a summary report like the one below

stop_code stop_def sum count
--------- ------------ --- -----
0122 fuse trip 25 2
0123 breaker trip 92 2

tricky point is the duration and the continue columns! in the report, i want the total sum for every group but the count od groups should neglect the records with the 'X' .

i did this with a temporary table and then a select.
is there a one shot solution?
   

- Advertisement -