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 2005 Forums
 Transact-SQL (2005)
 Anything wrong?

Author  Topic 

knockyo
Yak Posting Veteran

83 Posts

Posted - 2007-11-21 : 20:59:50
Hi all,

actually i want to sum all the values with same Equip Name, but it failed? why.....

SELECT EquipmentName, ShiftName, SUM(PSTOTALSEC) AS [PSTOTALSEC]
FROM EMHISTORY
WHERE PreviousState='RUN' AND ShiftName='Normal'
AND DateNtime>='10-July-2007 08:00' AND DateNtime<='11.Jul.2007 20:00'
GROUP BY EquipmentName,ShiftName,DateNtime,PSTOTALSEC

result:
EquipName ShiftName Sec
------------------------------------------
Cure Conveyor 4 Normal 52
Encap 2 Normal 171
Encap 3 Normal 46
WB 7 Normal 52
Wirebond 1 Normal 34
Wirebond 5 Normal 54
Wirebond 5 Normal 183

Please advice

medtech26
Posting Yak Master

169 Posts

Posted - 2007-11-21 : 21:15:50
grouping DateNtime brings differ results for each date/time

GROUP BY EquipmentName,ShiftName(,PSTOTALSEC?)
Go to Top of Page

knockyo
Yak Posting Veteran

83 Posts

Posted - 2007-11-21 : 21:50:05
hi,

actually i need to filter date and time as well, any idea to sum out?
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-11-21 : 23:17:03
[code]SELECT EquipmentName, ShiftName, SUM(PSTOTALSEC) AS [PSTOTALSEC]
FROM EMHISTORY
WHERE PreviousState = 'RUN'
AND ShiftName = 'Normal'
AND DateNtime >= '10-July-2007 08:00'
AND DateNtime <= '11.Jul.2007 20:00'
GROUP BY EquipmentName, ShiftName[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

knockyo
Yak Posting Veteran

83 Posts

Posted - 2007-11-22 : 01:55:10
thx.. :D
Go to Top of Page
   

- Advertisement -