запрос не получается :(

Maybe
Дата: 14.10.2003 09:31:58
select dbo.temptable1.object_name as k1,
sum(case habit WHEN 1 THEN count1 ELSE 0 END) AS ftr1,
sum(case habit WHEN 2 THEN count1 ELSE 0 END) AS ftr2,
sum(case habit WHEN 3 THEN count1 ELSE 0 END) AS ftr3,
(ftr1+ftr2+ftr3) as total
into temptable2 from temptable1
group by object_name

ругается на ftr1-ftr3
Павел Воронцов
Дата: 14.10.2003 09:34:24
select dbo.temptable1.object_name as k1, 

sum(case habit WHEN 1 THEN count1 ELSE 0 END) AS ftr1,
sum(case habit WHEN 2 THEN count1 ELSE 0 END) AS ftr2,
sum(case habit WHEN 3 THEN count1 ELSE 0 END) AS ftr3,
(ftr1+ftr2+ftr3) as total
into temptable2 from temptable1
group by object_name, (ftr1+ftr2+ftr3)
iSestrin
Дата: 14.10.2003 09:45:36
правильно ругается, алиасы нельзя использовать в селект-листе, оберни это еще одним селектом, т.е. вложенный запрос
afddsfsdf
Дата: 14.10.2003 10:08:03
не помогло :(
что делать?
Maybe
Дата: 14.10.2003 10:10:24
isesrtin, как?
iSestrin
Дата: 14.10.2003 10:11:23
что не помогло? так пробовал?

select k1, ftr1,ftr2,ftr3, (ftr1+ftr2+ftr3) total
into temptable2 from
(select dbo.temptable1.object_name as k1,
sum(case habit WHEN 1 THEN count1 ELSE 0 END) AS ftr1,
sum(case habit WHEN 2 THEN count1 ELSE 0 END) AS ftr2,
sum(case habit WHEN 3 THEN count1 ELSE 0 END) AS ftr3
from temptable1
group by object_name ) a
tpg
Дата: 14.10.2003 10:28:54
Или так
select dbo.temptable1.object_name as k1, 

sum(case habit WHEN 1 THEN count1 ELSE 0 END) AS ftr1,
sum(case habit WHEN 2 THEN count1 ELSE 0 END) AS ftr2,
sum(case habit WHEN 3 THEN count1 ELSE 0 END) AS ftr3,
(
sum(case habit WHEN 1 THEN count1 ELSE 0 END)
+sum(case habit WHEN 2 THEN count1 ELSE 0 END)
+sum(case habit WHEN 3 THEN count1 ELSE 0 END)
) as total
into temptable2 from temptable1
group by object_name
Maybe
Дата: 14.10.2003 10:47:00
isestrin, tpg, спасибо