New answers tagged

0

View detail log and change permission to 0600. It work with me DETAIL: File must have permissions u=rw (0600) or less if owned by the database user, or permissions u=rw,g=r (0640) or less if owned by root.


0

A more dynamic approach would be , getting the lowest Number and the highest and building the m missing from there. If you don't have a leading 2 like in the example 2006004 you need to pad the generated part CREATE TABLE documents ( "order_id" VARCHAR(22), "documentno" VARCHAR(12) ); INSERT INTO documents ("order_id", &...


1

One easy way is to generate a list of all potential documentnos and remove from that all the ones that exist: select 'YD4BC' || generate_series(2006004, 2006015) as missing_documentno except select documentno from documents;


1

To solve your issue, I did the following (a fiddle for all code below is available here): A couple of points: This solution makes use of the LAG() window function. Window functions are very powerful and will repay any effort spent learning them many times over. And finally, PostgreSQL 9.5 is no longer supported - you might be better off moving to a ...


1

Without CTEs and window functions: SELECT colony, MIN(date_in) date_in, date_out FROM ( SELECT t1.colony, t1.date_check date_in, MAX(t2.date_check) date_out FROM test t1 JOIN test t2 ON t1.colony = t2.colony AND t1.date_check < t2.date_check AND t1.protection = 'Y' AND t2.protection = '...


0

Only solution so far is via bash script: #!/bin/bash user=myuser host=127.0.0.1 database=mydb batch_size=10000 elements=$( psql -X -A -U $user -h $host -d $database -t -c "SELECT COUNT (*) FROM vacuum_l where deleted = false" ) echo "los to unlink:" echo $elements echo num_batches=$((elements / batch_size)) num_batches=$((num_batches + 1)...


4

A correlated subquery against a VALUES table should do the trick: SELECT t.A, t.B, t.C, (SELECT COUNT(DISTINCT v.n) FROM (VALUES(t.A),(t.B),(t.C)) AS v(n)) AS cnt FROM table t If you wanted separate calculations on the values such as both counting and summing, you could use a lateral join (a.k.a APPLY) over VALUES instead: SELECT A, B, C ,D, E, v....


1

You can use nested CASE WHEN structure CREATE TABLE test ( "A" INTEGER, "B" INTEGER, "C" INTEGER, "cnt" INTEGER ); INSERT INTO test ("A", "B", "C", "cnt") VALUES ('2', '1', '2', '0'), ('1', '5', '5', '0'), ('2', '1', '4', '0'), ('1', '1', '1', '0'); UPDATE ...


Top 50 recent answers are included