with x as (select -1 stat) select * from {tabela zawierająca kolumne status - wartości intowe m.in 1,2,100} where status in
( -- select ( case when (select stat from x) = -1 then (select s from unnest(array[1,2]) s) else (select stat from x) end -- )::regclass
)
order by id asc limit 10 Jak w with dam żeby stat = (jakikolwiek int) to filtruje prawidłowo, jeżeli dam -1 to dostaję błąd ERROR: more than one row returned by a subquery used as an expression. Jak do klauzuli IN "dostarczyć" wartości z unnest(array) ?
@Hauleth: filtrować tabelę po kolumnie status za pomocą ... where status in ... i do IN w zaleznosci od wartosci w with x as (select -1 stat), to: jeżeli stat = -1 to ma być warunek status in (1,2) a jeżeli stat = każdy inny int to status =/in stat
with x as (select -1 stat)
select * from {tabela zawierająca kolumne status - wartości intowe m.in 1,2,100}
where status in
(
-- select (
case
when (select stat from x) = -1 then (select s from unnest(array[1,2]) s)
else (select stat from x)
end
-- )::regclass
)
order by id asc
limit 10
Jak w
withdam żeby stat = (jakikolwiek int) to filtruje prawidłowo, jeżeli dam-1to dostaję błądERROR: more than one row returned by a subquery used as an expression. Jak do klauzuliIN"dostarczyć" wartości zunnest(array)?#programowanie #postgresql #sql
statusza pomocą... where status in ...i doINw zaleznosci od wartosci wwith x as (select -1 stat), to: jeżeli stat = -1 to ma być warunekstatus in (1,2)a jeżeli stat = każdy inny int tostatus =/in statWHERE (state = -1 AND status IN (1, 2)) OR (state <> -1 AND status = state)