Версия для печати темы
Нажмите сюда для просмотра этой темы в оригинальном формате
Форум программистов > СУБД, общие вопросы > Переименование полей


Автор: geckelberryfinn 18.8.2006, 17:50
Так, либо я уже туплю под вечер в пятницу, либо DB2

Почему в результате выполнения запроса

Код

with
alterstrukt(
bid,
name, 
monate3,
monate6,
monate9,
monate12,
monategt12,
gesamt, 
gt6, 
percent) 
as 
(select 
bid, 
de.modelname, 
(sum(case when carmodelid<>0 then case when de.delta<=91  then 1 else 0 end else null end)) as "0 - 3 Monate",
sum(case when carmodelid<>0 then case when (de.delta>91) and (de.delta<=182) and carmodelid<>0 then 1 else 0 end else null end)  as "4 - 6 Monate",
sum(case when carmodelid<>0 then case when  (de.delta>182) and (de.delta<=274) and carmodelid<>0 then 1 else 0 end else null end) as  "7 - 9 Monate",
sum(case when carmodelid<>0 then case when (de.delta>274) and (de.delta<=365)and carmodelid<>0 then 1 else 0 end else null end) as "10 - 12 Monate", 
sum(case when carmodelid<>0 then case when  (de.delta>365)  and carmodelid<>0 then 1 else 0 end else null end) as  ">12 Monate",
sum(case when carmodelid<>0 then case when (de.delta>=0)and carmodelid<>0 then 1 else 0 end else null end) as  "gesamt",
sum(case when carmodelid<>0 then case when (de.delta>182) and carmodelid<>0  then 1 else 0 end else null end) as " >6 monate",
(sum(case when carmodelid<>0 then case when (de.delta>182) and carmodelid<>0  then double(1) else 0 end else null end)/sum(case when (de.delta>=0) then double(1) else 0 end)*100) as "%"
 from deltas de group by de.bid,modelname,n)

select * from alterstrukt


колонки имеют имена monate3, monate6 и т.д. хотя я вроде явно ввел переименование. 
при этом тупой запрос типа 
Код

select sum(case when sales.order.carorder_state =8 then 1  else null end)  as "SUMMA" from sales.order

отображается корректно. 
Есть идеи?

Автор: geckelberryfinn 18.9.2006, 10:49
да.... давно хотел пометить как решенную. Пусть будет памятником моему пятничному тупизму. Переименовывание работает только в последнем select. 

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)