Aktualizacja czas wydarzenia o okres 5 min
update events_time
set
ev_time_end = ev_time_start + '5 minute' :: interval
where
ev_id = 5
Aktualizacja czas wydarzenia o okres 5 min
update events_time
set
ev_time_end = ev_time_start + '5 minute' :: interval
where
ev_id = 5
select
regexp_replace(
url,
E'^http:\/\/.*\/(.*)-(\\d+).html(\\?)?(.*)?',
E'\\1'
) as t_name,
regexp_replace(url, E'^.*-(\\d+).html(\\?)?(.*)?', E'\\1') :: integer as t_id,
count(*) as t_cnt
from unnest(
ARRAY [
'http://kody.wig.pl/ustawienie_wartosci_pol_input_w_formularzu_strony-15.html',
'http://kody.wig.pl/ustawienie_wartosci_pol_input_w_formularzu_strony-15.html?
action=test&value1=118-115&value2=119-116'
]
) as t(url)
group by
t_name,
t_id
Wynik:
"ustawienie_wartosci_pol_input_w_formularzu_strony";15;2
Dodanie pola do tabeli:
ALTER TABLE posts ALTER COLUMN post_tags TYPE character varying[]
USING CASE WHEN post_tags IS null THEN null ELSE string_to_array(post_tags, ', ') END;
select post_tags, string_to_array(post_tags, ',') from posts where
post_tags is not null limit 5;
-- split_part(post_tags, ',', 2);
SELECT (
extract('hour' FROM '16:00:00'::interval) - extract('hour' FROM '10:00:00'::interval)
)*3;
Obliczanie różnicy godzin i pomnożenie przez 3
Przykładowy sql:
select *, length(p_path::path) as distance from (select *, p.p_name, '((54.175540523964, 15.527111972064), ('||p_lat::text||','||p_lng::text||'))' as p_path
from
points p
where
p.p_status (p.m_id=5
or
(51.175540 < p_lat and p_lat < 57.17554 and 12.52711 < p_lng and p_lng < 18.52711))
order by
p.m_id=5 DESC nulls last) t
order by distance asc limit 6