Нашли или выдавили из себя код, который нельзя назвать нормальным,
на который без улыбки не взглянешь?
Не торопитесь его удалять или рефакторить, — запостите его на
говнокод.ру, посмеёмся вместе!
select *
from ( select ... ,
case
when txn_minute >= date '2014-08-01'
and txn_minute < date '2014-08-02'
then
'1 августа'
when txn_minute >= date '2014-08-02'
and txn_minute < date '2014-08-03'
then
'2 августа'
when txn_minute >= date '2014-08-03'
and txn_minute < date '2014-08-04'
then
'3 августа'
when txn_minute >= date '2014-08-04'
and txn_minute < date '2014-08-05'
then
'4 августа'
when txn_minute >= date '2014-08-05'
and txn_minute < date '2014-08-06'
then
'5 августа'
.....
when txn_minute >= date '2014-08-31'
and txn_minute < date '2014-09-01'
then
'31 августа'
end
"Дата"
from txn
where txn_minute >= date '2014-08-01'
and txn_minute < date '2014-09-01'
group by .....
.....
end) pivot (sum (am)
for "Дата"
in ('1 августа',
.....
'29 августа',
'30 августа',
'31 августа'))
Комментарии (3) RSS