不大明白你的意思 第一个问题有什么可说的吗? select sum(table1.TotaArea) where date between 'xxxx-xx-xx' and 'xxxx-xx-xx' and person='xxxx' 第二个问题更晕,一点也不理解你的意思了,只是猜一下 select newtotalarea = case len(totalarea) where 1 then totalarea * 2 when 3 then totalarea * 5 end from talbe1 where .....
select AreaName,Person1, Sum( case BoxStuff when 1 then 1.5*TotalArea case BoxStuff when 2 then 1.5*TotalArea case BoxStuff when 3 then 1.5*TotalArea case BoxStuff when 6 then 1.5*TotalArea case BoxStuff when 7 then 1.5*TotalArea case BoxStuff when 8 then 1.5*TotalArea case BoxStuff when 9 then 2*TotalArea else TotalArea ) from table1 where date between '2002-01-01' and '2002-01-23' group by AreaName,Perspon1
欲查询某段时间内某个AreaName,某个Person的TotalArea之和。另外要根据BoxStuff的内容来算TotalArea.(根据BoxStuff中字母的个数来算TotalArea,比如A-A-B表示有三层。"-"不算。如果有1,2,3层TotalArea*1.5.4,5层不变。6,7,8层则TotalArea*1.5 .9层的话则是TotalArea*2.最多有9层。),请问如何写这样的视图。
不大明白你的意思 第一个问题有什么可说的吗? select sum(table1.TotaArea) where
date between 'xxxx-xx-xx' and 'xxxx-xx-xx' and person='xxxx'
第二个问题更晕,一点也不理解你的意思了,只是猜一下
select newtotalarea = case len(totalarea) where 1 then totalarea * 2 when 3 then totalarea * 5 end from talbe1 where .....
Sum(
case BoxStuff when 1 then 1.5*TotalArea
case BoxStuff when 2 then 1.5*TotalArea
case BoxStuff when 3 then 1.5*TotalArea
case BoxStuff when 6 then 1.5*TotalArea
case BoxStuff when 7 then 1.5*TotalArea
case BoxStuff when 8 then 1.5*TotalArea
case BoxStuff when 9 then 2*TotalArea
else TotalArea
)
from table1
where date between '2002-01-01' and '2002-01-23'
group by AreaName,Perspon1