Skip to content

Tag: sql

How we can loop over SQL Column with specific condition

Explanations: In 1st picture data we have. In the 2nd picture report we want to generate using SQL. In the last we have added table and data script Column Calculation = 2(Yes)/3(Total Column Contain Yes/NO) *100 Sample data: Answer You need to unpivot the CL values first and then implement a dynamic pivot: Re…

Denormalization table – SQL Select (Pivot Table?)

CAMPAIGN table ID campaign_name 1 Campaign A 2 Campaign B PARTICIPANT table ID campaign_id participant_name 1 1 Alice 2 1 Ben CUSTOM_FIELD table ID campaign_id field_name 1 1 Gender 2 1 Age FIELD_ANSWER table ID participant_id field_id answer 1 1 1 Female 2 1 2 24 3 2 1 Male 4 2 2 28 With these tables in abov…

Unable to create DB2 Procedure through command line

I am trying to create a procedure to do a blanket revoking of executeauth for procedures from a schema. This is in line with trying to secure a non-restricted database. and this is the command I run to process the file with the code above. However, I keep running into this error I’m fairly new to DB2 an…

Select the Max row number for an account

I need to only pull the max row number for an account. I know it’s a grouping issue. Current data: ACCOUNT_UID ID NAME ACADEMIC_PERIOD CAT_BY_DATE CAT_DATE MAX_ROW abc abc Popeye 202190 CPT 9/15/2021 1 abc abc Popeye 202190 CSH 10/4/2021 2 I only need the second row. Current query: Answer You can try th…