sql - Combining Rows and Taking Averages -
i have table looks
#sector max1 avg1 max2 avg2 numb c 133 14 45 3 27 n 174 9 77 3 18 m 63 3 28 1 16
i join rows n , m call x , take max value of max1 , max2 while taking avg of avg1, avg2, , numb in respective columns return
#sector max1 avg1 max2 avg2 numb c 133 14 45 3 27 x 174 6 77 2 17
try way:
select sector, max1,avg1,max2,avg2,numb tab sector not in ('m','n') union select 'x' sector, max(max1),avg(avg1),max(max2),avg(avg2),avg(numb) tab sector in ('m','n')
Comments
Post a Comment