i have a problem, i would like use 2 select to insert in new table but i don’t know if it’s possible… my code : I would like insert the second part ( select COLONNE01….) in the first part instead of “INSERT HERE” DATA OLD TABLE : COLUMNS 1 (“PKID1″, one”,&…
Tag: lateral-join
How to include OPENJSON in View?
My JSON object is stored in the table (single cell). Right now, I’m reading the cell and saving the value to @json NVARCHAR(MAX) , but that obviously doesn’t work in views. How can I do something like this? Answer You can use cross apply to apply openjson() to each and every row of your table:
Rolling Sum for Last 12 Months in SQL
I’m trying to get the rolling sum for the past 12 months (Oct 2019-Sept 2020, etc.)> So far, I figured out to get the current year total (which I also want), however, I’m stuck on a legit 12 month rolling sum. here’s what my current output looks like AS you can see, it resets at the begin…
logic to create more rows in sql
I have a table1 that I wanted to transform into the expected table. Expected table logic for columns: cal: comes from cal of table1. ID comes from the ID of table1. code: this is populated with lp or fp depending upon if we have a value in f_a then we create a new record with fp as code. corresponding to
Is it possible to use dynamic columns multiple times in a select?
I have some complex string replacement and I’m only permitted read-only access. I’d like to have several columns where each is dependent on the previous column so I can see if my substring and …
PostgreSQL parse countries in array against the countries table
We have content and country tables. Country is pretty simple: country_name column defined as string: Albania, Belgium, China, Denmark etc… Content is a table with half a million of rows with various data with countries column defined as array text[]. Each value there has a number of countries concatenat…
Can PostgreSQL JOIN on jsonb array objects?
I am considering switching to PostgreSQL, because of the JSON support. However, I am wondering, if the following would be possible with a single query: Let’s say there are two tables: Table 1) organisations: Table 2) users: Now I want to get a result like this (all i have is the ID of the organisation […
What is the difference between LATERAL JOIN and a subquery in PostgreSQL?
Since Postgres came out with the ability to do LATERAL joins, I’ve been reading up on it, since I currently do complex data dumps for my team with lots of inefficient subqueries that make the overall …