Skip to content

Tag: sql-server

Find missing rows between three related tables

I have three tables: Person Dates Absence I need to find all of the person_id’s in the Person table and the date’s from the Dates table who have not booked any absence matching the following criteria: Dates.date_type = ‘PUBLIC_HOLIDAY’ Absence.absence_type = ‘HOLIDAY’ Basic…

Using BOTH scalar values and JSON objects as JSON values

I have a local table variable that I’m trying to populate with JSON key-value pairs. Sometimes the values are themselves JSON strings An example of what this ends up looking like: After populating it, I attempt to build it all up into a single JSON string, like so: The problem with this is that it turns…

UPDATE command in a JSON

I’m trying to update a column in my table, but that column stores a JSON Object, but for that I need to do a where with a JSON as well. This is how the data is stored in my RG column: { “Id”:”…

SQL Recursive Count

I have two tables I am joining with the following structure: A ContentDivider can have n ContentDividers as Children and can have m CustomPages as children as well. I want a View that counts the Display the current CustomDivider and the COunt for all the CustomPages as Children of the current ContentDivider. …

SELECT to return duplicate distinct column values

Tying to have query that can duplicate some column values based off values in other columns. ID1 column will always have a value and ID2 and ID3 may or may not. Data in table looks like this. Wanting to to query this table to show resultset like this Been stabbing at this trying case selects, and inserting in…