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 |
Gili
Starting Member
42 Posts |
Posted - 2008-01-16 : 06:49:25
|
Hi,i have table with this structure :customer | sale1 | sale2 | sale3 |arik | 5 | 6 | 0i want to make avg of sale1,sale2,sale3 per row and where the value is 0 not take in the avg. like this 5+6 = 11/2 and not 5+6+0=11/3any ideas plz?thanks. |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-01-16 : 07:34:40
|
Try thisSelect customer,avg(sale1) as average from(select customer,sale1 from tableunion allselect customer,sale2 from tableunion allselect customer,sale3 from table) as twhere sale1>0group by customerMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|