Skip to content
Advertisement

Tag: common-table-expression

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 You need to SELECT from the CTE:

WITH queries with INSERT in MySQL

I’m trying to do something that I’m almost positive works in Postgresql: In other words, I want to grab the “something” row to be used for a bunch of new rows in “somwhere”. Each new entry should have a reference (like foreign key value) back to the same “something” row in the cte, mostly just to avoid a mess. However,

Trying to delete duplicate rows in SQL Server where the difference is the date or batch number

I have this query: Which is returning the following results ID_NUMBER INCEPTION_DATE OCCURRENCE TRANSACTION_DATE FILE_LOAD_DATE BATCH_NUM 112897732 2008-09-15 4 2008-07-03 2008-07-07 17:57:19 06341 112897732 2008-09-15 4 2008-07-13 2008-07-18 03:35:55 06753 828194721 2008-11-11 1 2008-09-06 2008-09-17 02:50:44 97334 828194721 2008-11-11 1 2008-09-23 2008-09-24 02:55:27 98331 456457422 2008-09-28 1 2008-12-03 2008-07-13 08:08:39 00734 456457422 2008-09-28 1 2008-12-03 2008-07-18 13:35:55 00991 999272910 2008-05-07

Advertisement