Skip to content
Advertisement

Insert query with a column that is the total number of records from another table

I have a query that inserts data from another table, into an empty table (the table is cleared once a day, and new data is put in once a day). Currently it looks like this:

What I would like to do, is include a row called “COUNT” on the insert, that would be total number of records of the table “finaltable”.

Something like:

But I have no idea how I would go about that, I’m not super familiar with subqueries like this.

Advertisement

Answer

One way is to use windowed COUNT:

db<>fiddle demo

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement