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.
| 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,PSTOTALSECresult:EquipName ShiftName Sec------------------------------------------Cure Conveyor 4 Normal 52Encap 2 Normal 171Encap 3 Normal 46WB 7 Normal 52Wirebond 1 Normal 34Wirebond 5 Normal 54Wirebond 5 Normal 183Please advice  |
|
|
medtech26
Posting Yak Master
169 Posts |
Posted - 2007-11-21 : 21:15:50
|
| grouping DateNtime brings differ results for each date/timeGROUP BY EquipmentName,ShiftName(,PSTOTALSEC?) |
 |
|
|
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? |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-11-21 : 23:17:03
|
[code]SELECT EquipmentName, ShiftName, SUM(PSTOTALSEC) AS [PSTOTALSEC]FROM EMHISTORYWHERE 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] |
 |
|
|
knockyo
Yak Posting Veteran
83 Posts |
Posted - 2007-11-22 : 01:55:10
|
| thx.. :D |
 |
|
|
|
|
|
|
|