Question: SELECT section _ name, MAX ( IF ( EXTRACT ( YEAR FROM trunc _ month ) = 2 0 2 4 AND EXTRACT ( MONTH
SELECT
sectionname,
MAXIFEXTRACTYEAR FROM truncmonth AND EXTRACTMONTH FROM truncmonth totaldistinctusers, NULL AS January
MAXIFEXTRACTYEAR FROM truncmonth AND EXTRACTMONTH FROM truncmonth totaldistinctusers, NULL AS February
MAXIFEXTRACTYEAR FROM truncmonth AND EXTRACTMONTH FROM truncmonth totaldistinctusers, NULL AS March
MAXIFEXTRACTYEAR FROM truncmonth AND EXTRACTMONTH FROM truncmonth totaldistinctusers, NULL AS April
MAXIFEXTRACTYEAR FROM truncmonth AND EXTRACTMONTH FROM truncmonth totaldistinctusers, NULL AS May
MAXIFEXTRACTYEAR FROM truncmonth AND EXTRACTMONTH FROM truncmonth totaldistinctusers, NULL AS June
MAXIFEXTRACTYEAR FROM truncmonth AND EXTRACTMONTH FROM truncmonth totaldistinctusers, NULL AS July
MAXIFEXTRACTYEAR FROM truncmonth AND EXTRACTMONTH FROM truncmonth totaldistinctusers, NULL AS August
MAXIFEXTRACTYEAR FROM truncmonth AND EXTRACTMONTH FROM truncmonth totaldistinctusers, NULL AS September
MAXIFEXTRACTYEAR FROM truncmonth AND EXTRACTMONTH FROM truncmonth totaldistinctusers, NULL AS October
MAXIFEXTRACTYEAR FROM truncmonth AND EXTRACTMONTH FROM truncmonth totaldistinctusers, NULL AS November
MAXIFEXTRACTYEAR FROM truncmonth AND EXTRACTMONTH FROM truncmonth totaldistinctusers, NULL AS December
FROM
productiondata.feboverallfeatureusage
GROUP BY
sectionname
order by sectionname
In this code I am transposing month names from rows to columns, which is a pivot. Now, I want to change this to remove all column names which are months from the future. I am using bigquery.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
