select
u_id,
case
when work_start > '2012-12-01'::date then work_start
else '2012-12-01'::date
end::date + generate_series(1, 31) - 1 as ndate
from n_users
where
u_id = 300
4 sty 2013
select
u_id,
case
when work_start > '2012-12-01'::date then work_start
else '2012-12-01'::date
end::date + generate_series(1, 31) - 1 as ndate
from n_users
where
u_id = 300
select
a_title,
regexp_replace(a_title, ' +', ' ', 'g')
from articles
where
a_status = 't'
and a_title ~ ' '
update articles
set
a_title = regexp_replace(a_title, ',', ' ')
where
a_status = 't'
and a_title ~ ','
update articles
set
a_title = regexp_replace(a_title, ' +', ' ', 'g')
where
a_status = 't'
and a_title ~ ' '
select czas, date_trunc('day', czas)+'15:59:12' as czas2 from czas limit 1;
UPDATE czas set czas = date_trunc('day', czas)+'15:59:12' WHERE wt_id = 3850;
"2008-11-07 15:58:37";"2008-11-07 15:59:12"
select
czas, date_trunc('day', czas), date_trunc('day', timestamp '2010-08-11')
from
czas_t
where
date_trunc('day', czas) = date_trunc('day', timestamp '2010-08-11')
"2010-08-11 07:37:46";"2010-08-11 00:00:00";"2010-08-11 00:00:00"
"2010-08-11 07:40:49";"2010-08-11 00:00:00";"2010-08-11 00:00:00"
"2010-08-11 08:04:42";"2010-08-11 00:00:00";"2010-08-11 00:00:00"
"2010-08-11 09:12:32";"2010-08-11 00:00:00";"2010-08-11 00:00:00"
"2010-08-11 08:55:52";"2010-08-11 00:00:00";"2010-08-11 00:00:00"
"2010-08-11 15:59:12";"2010-08-11 00:00:00";"2010-08-11 00:00:00"
delete from comments
where
comment SIMILAR TO '%(insurance|payments|health)%'
usuwanie rekordów
select substring(n_text,1, 30) || substring(substring(n_text, 31, 15), '[^ ]*') || ' ...' as n_text from texts