Skip to content

Tag: sql

Create a flag to know if a column is in multiple intervals

I am struggling in SQL to create a flag based on an interval. This is my use case: Table: result merchandising_month client_id start_month_12m_before end_month_12m_before start_month end_month 202106 client1 201910 202009 202010 202109 202006 client1 201910 202009 202010 202109 202003 client2 201910 202009 20…

Case statements with Join on lookup

I have a big table with some columns having lookup values. I want to create a description column for each lookup column and populate them with description from lookup table. Here is one example main table id1 id2 id3 1 2 3 1 3 4 look up table code id desc id1 1 id1-desc1 id2 2 id2-desc2 id2 3 id2-desc3

Return first element of each cell

I have a table like this: Id Description Recipient 1 lipsum 35235 2 dolor est 123, 456, 2432 3 Lorem Ipsum 143243, 34, 2344 And I’d like an output like this: Id Description Recipient RecipientId 1 lipsum 35235 35235 2 dolor est 123, 456, 2432 123 3 Lorem Ipsum 143243, 34, 2344 143243 I need to join a ta…