0

どのように組み合わせて値を出力できますか。クエリがあり、その下に3つの値がありIt.Financeます。高、中、低を想定しています。中と低を平均として組み合わせたいので、出力値は次のようになります。

高い

平均(中および低)

select  count(h.Dept_id) as DeptCount,

i.Id as CompanyId,

i.Account as AccountTotal,

i.Technology as IT,

ISNULL(it.Finance,'NoCapacity') as School

from Institution i left join 

 History h on h.Institution_id = i.Id left join 

   xxxxx

   yyyyy      

group by i.Id,i.Account,i.Technology,it.Finance

出来ますか?

4

1 に答える 1

0

最良の盲目的な推測:

select  count(h.Dept_id) as DeptCount,
i.Id as CompanyId,
i.Account as AccountTotal,
i.Technology as IT,
coalesce(it.Finance,'NoCapacity') as School,
Max(it.Finance) as High, 
(Avg(it.Finance) + Min(it.Finance))/2 as Average
from Institution i left join 
History h on h.Institution_id = i.Id left join 
   xxxxx -- your unknown tables
   yyyyy -- your unknown tables     
group by i.Id, i.Account
于 2013-01-14T23:21:13.170 に答える