I have a db with a primary key address I want to write a request that would delete rows that match the address that I pass in the array. I have this in my missing-urls.js file and use this query in my query/missing-urls.js file When I run this request I got an error. What I am doing wrong? Answer You
Tag: postgresql
Query condition where a value is in a comma separated string
I have a table in which one of the table columns third_row stores a comma-separated list of numbers as a string but when its value is A then it means a combination of all the possible numbers. How do I approach this so that the query returns all the rows that have the third_row as A and the rest where
raise notice update query result in postgresql
How can I log if field is got updated or not using RAISE NOTICE or some other command if available. Error: Answer I could something like below, but I am not sure if there another UPDATE query followed by current one, ROW_COUNT will hold new result;
How can I insert a value from another table to another on insertion?
I have this table called users. Whenever I sign up a user, I generate an UUID for him. When this UUID is generated I want to insert a row in another table called health, with the same UUID that was inserted on the users table. I was trying to make this way, but I can’t make it work: I’m having
I need to get count of total count for the query I had in postgresql
I created a select query as following, now I need to get the total count of the “No.of Ideas generated” column in a separate row as total which will have a count of the individual count of particular idea_sector and idea_industry combination. Query: Output: Required output: Answer You can accomplish this with grouping sets. That’s where we tell postgres, in
Django ORM compare tuples / lexicographic ordering
As part of some custom cursor-based pagination code in Python Django, I would like to have the below filtering and ordering on a generic Queryset (where I don’t know the table name up front) How can this be expressed in terms of the Django ORM? Note I would like the SQL to keep the tuple comparison and not have this
is it possible to do a conditional concat?
I have a query that pulls different data but for one field it concats its since the URL is partially filled in my db but the problem is if logourl is blank then I just get https://my_url.com instead of the full URL. This is having down stream impact. Is there a way to only concat if logurl is not null?
Write columns as rows (PostgreSQL)
I have a table: campaign_id media installs content_view date unique_purchase 7564 google 613 45 2021-09-01 1 7564 facebook 21 33 2021-09-02 2 3451 google 83 12 2021-09-01 0 I want to create view: write installs column values as metric_key=installs, metric_name=installs, metric_value=… write content_view and unique_purchase as metric_key=event, metric_name=column_name, metric_value=… id media_source metric_key metric_name metric_value date 7564 google installs installs 613
Postgres – How to achieve UNION behaviour with UNION ALL?
I have a table with parent and child ids. Each parent can have multiple children and each child can have multiple children again. The data looks like this. I’d like to find all children. I can use a recursive cte with a UNION ALL. This gives me the result I’d like to achieve. However I’d like to include the depth
How to pivot in postgresql
I have table like following,and I would like to transform them. I’d like to pivot like following. I tried like following statement, but it returned a lot of null columns. And I wonder I must add columns one by one when new type will be added. If someone has opinion, please let me know. Thanks Answer demo: db<>fiddle You can