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 |
partap26
Starting Member
27 Posts |
Posted - 2013-06-06 : 07:58:38
|
SELECT sd.site_id, avg(av.dc_volt) as dc_volt, avg(av.curr_temp) as curr_temp,SUM(at.eb_time) as eb_time, SUM(at.bb_time) as bb_time, SUM(dg_time) as dg_timeFROM site_details sdINNER JOIN avg_values av ON av.site_id = sd.site_idINNER JOIN alarm_count ac ON ac.site_id = sd.site_idINNER JOIN alarm_time at ON at.site_id = sd.site_idWHERE sd.site_id='S001'GROUP BY sd.site_id, sd.site_name;The output isS001, 43.00, 21.00, 145800, 44220, 141516But the actual SUM of eb_time value for S001 is 12150. I think so tha problem is with INNER JOIN and when i remove the join the value start to decrese and when there is only on join then i found the actual value......... |
|
ditch
Master Smack Fu Yak Hacker
1466 Posts |
Posted - 2013-06-06 : 08:01:07
|
Look up LEFT JOIN in Books online..... or Outer JoinDuane. |
 |
|
partap26
Starting Member
27 Posts |
Posted - 2013-06-06 : 08:40:37
|
Also not working fine with LEFT JOIN and LEFT OUTER JOIN ..... |
 |
|
ditch
Master Smack Fu Yak Hacker
1466 Posts |
Posted - 2013-06-06 : 09:20:14
|
Post your code using left outer join.Duane. |
 |
|
|
|
|