Skip to content

Dynamically SELECT a column based on value of row at first of month

The following query: Returns the following sample data: Where on the first of the month, Confirmed = Y, I need to return the Declared column for that month. Note, Confirmed = Y will only exist on the first of the month. That column is blank in all other cases Otherwise, I need to return each Interim column fo…

sql nested “sum (case when) or” select query

I have a select query where I am trying to sum a value based on multiple criteria, grouped by dimension. The output will be the sum of the time greater than 30, 90, or 365 days based on the category, grouped by category. I can’t crack the syntax for this, I hope you can help! The concept looks something…

Just get one data if duplicate (not DISTINCT)

I have the following result from a query in mysql (headers: depicao, arricao): EDDH, EDDK EDFH, EDDL EDDS, EDDH EDDK, EDDH My problem is now, that I just want one of the rows, IF the data exist in …

Add rows to SQL table based on a list of values

So I have a table like this and an attribute list – (‘attr1’, ‘attr2’, ‘attr3’). id | attr_name | attr_value —————————- 1 | attr1 | val1 1 | attr2 | val2 1 | attr3 …