Skip to content

SQL Merge update

my merge query MERGE Povertytgt t USING Povertyrsc s ON (s.Incomegroup = t.Incomegroup ) WHEN MATCHED THEN UPDATE SET t.CountbyGroup = s.CountbyGroup; and got error The …

SQL Join query with a null in Main table

Hi guys so in simple terms I have a Main table “A” and then another table “B”. All the data I want is basically from table A, but to figure one part out I need to join with B. My problem is although the column im joining with a column in B is correct, sometimes the column in A will

Conditional Grouping in SQL

This should be easy, but I’m having trouble with it. I have a results table that looks like this: Notice that the pct column sums to 1.0 for each store. Here’s the code to create this table: I’m trying to group the results by store, then by cust_id while creating a new category A&B if th…