Skip to content

Tag: sql

SQL – How to use a value from INSERTed table

I am trying to insert a new location record in my db … and then reuse the value of the newly created id in a select statement’s where clause later on. But I’m getting a syntax error. Code: The error is “Must declare scalar variable” and it dies on there WHERE clause in the SELECT…

How to get list of ids into separate column

Problem statement: I have a table master_tab which consist of two columns e_id and owner_id. I want to list down the e_id’s which belong to owner_id 72 and 73. There is another condition that analysis_comp flag should be 1 in the table transaction_tab. My attempt: Tool used: SQL Developer(18c) Current O…

PostgreSQL: Using CTE with IN

Learning CTE right now, the following query is super basic and it doesn’t really have any useful value but I don’t understand why it doesn’t work The error I’m getting is “ERROR: column “cte_actors” does not exist” Currently using postgres 14 and DBeaver Answer …