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
 Transact-SQL (2000)
 Group By Time

Author  Topic 

Girlnet
Yak Posting Veteran

77 Posts

Posted - 2008-08-27 : 14:28:26
This query works except I don't want to group by op_time - only op_date. How would I modify the query?

SELECT op_wkctr as WC, op_part as PartNo,
case when datepart(hour,dateadd(s, op_time, op_date)) between 00 and 04 then dateadd(day,-1,op.op_date) else op.op_date end as RunDate,
op_wo_op as Op, op_shift as Shift, op_emp

FROM dbo.QAD_ro_det AS ro RIGHT OUTER JOIN
dbo.QAD_op_hist AS op ON ro.ro_routing = op.op_part AND ro.ro_wkctr = op.op_wkctr
and op_shift between 1 and 3
where (op_wkctr Like 'T-%' or op_wkctr Like 'P-%') and op_shift Between 1 and 3

GROUP BY op_wkctr, op_part, op_date, op_time, op_wo_op, op_shift, op_emp

Thanks in advance!

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-08-27 : 14:40:33
remove it from GROUP BY and apply MAX() or MIN() to time wherever you're using it
Go to Top of Page
   

- Advertisement -