Skip to content

Many to many join behaviour

Not really sure how to title this question, but here’s the situation. I have one data frame (dfOrders) that has an order_id and basic information like so: |order_id|full_name|order_date|billing|…

SQL Retrieve info from two tables

I am really lost with sql.. i tried to read everything but no luck. I have two tables and need to retrieve data from them: First Table – Workers | Second Table – Stores Select workers first name that belong to more than one store? Select all workers first name that are in the shoe store? Hope you …

Querying JSON (specific situation)

I am trying to query a specific example of JSON, see below: The column name is “values”. If I use values -> ‘members’ I will get everything underneath. However, if I want the “gender” using values …

SQL – Prepend a value if missing

Code/data: DECLARE @T TABLE ( [Col1] VARCHAR(20) , [RowNum] INT ) ; INSERT INTO @T VALUES ( N’second’, 1 ) , ( N’fifth’, 4 ) , ( N’fourth’, 3 ) –, ( N’zzz’, 1 ) …

get sum of all rows with id from main query

I need the sum of all positions from one year for every customer. In the subquery i’ve hardcoded the customernumber (mark 1) but it needs to be another customernumber for every row. The values in mark 2 are wrong. Thanks for your help! Answer If BAS_Customers and BAS_Contacts have a one-to-one relations…