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 |
|
Arithmomaniac
Yak Posting Veteran
66 Posts |
Posted - 2007-07-13 : 19:49:58
|
| SELECT sum([GroundShipments]), (sum(ExpressShipments)+sum(GroundShipments))from SHIPRUSH_INFO.dbo.vwFirstAttemptMashupwhere LastShipmentAtDT IS NOT NULLgroup by Carrier, CMGives, say,1,2; 5,7; 456,7678;butSELECT (sum([GroundShipments])/((sum(ExpressShipments)+sum(GroundShipments))))from ebay.dbo.vwFirstAttemptMashupwhere LastShipmentAtDT IS NOT NULLgroup by Carrier, CMcalculates, but gives all zeroes!Why? I've been having a lot of issues using two aggregates together. Are there special rules?Thanks,Arithmomaniac |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-07-13 : 19:54:02
|
integer divide by integer will give you back integer.So 1 / 2 = 0 and 5 / 7 = 0multiply it by 1.0 will force to convert the result of sum() to decimal valueSELECT (1.0 * sum([GroundShipments])/((sum(ExpressShipments)+sum(GroundShipments))))from ebay.dbo.vwFirstAttemptMashupwhere LastShipmentAtDT IS NOT NULLgroup by Carrier, CM KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-07-14 : 00:24:28
|
SELECT sum(1.0*[GroundShipments])/((sum(ExpressShipments)+sum(GroundShipments))))from ebay.dbo.vwFirstAttemptMashupwhere LastShipmentAtDT IS NOT NULLgroup by Carrier, CMTan what happened to your colours? MadhivananFailing to plan is Planning to fail |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-07-14 : 01:28:51
|
quote: Tan what happened to your colours?
Just woke up when i posted that. Have not had my daily [spoiler]cuppa[/spoiler] yet  KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-07-14 : 02:53:17
|
quote: Originally posted by khtan
quote: Tan what happened to your colours?
Just woke up when i posted that. Have not had my daily [spoiler]cuppa[/spoiler] yet  KH[spoiler]Time is always against us[/spoiler]
Too much color What does the hidden word mean?MadhivananFailing to plan is Planning to fail |
 |
|
|
Arithmomaniac
Yak Posting Veteran
66 Posts |
Posted - 2007-07-15 : 12:46:34
|
| Thank you. |
 |
|
|
|
|
|
|
|