Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Here is my code: SELECT section _ name, MAX ( IF ( EXTRACT ( YEAR FROM trunc _ month ) = 2 0 2 4

Here is my code:
SELECT
section_name,
MAX(IF(EXTRACT(YEAR FROM trunc_month)=2024 AND EXTRACT(MONTH FROM trunc_month)=1, total_distinct_users, NULL)) AS January_2024,
MAX(IF(EXTRACT(YEAR FROM trunc_month)=2024 AND EXTRACT(MONTH FROM trunc_month)=2, total_distinct_users, NULL)) AS February_2024,
MAX(IF(EXTRACT(YEAR FROM trunc_month)=2024 AND EXTRACT(MONTH FROM trunc_month)=3, total_distinct_users, NULL)) AS March_2024,
MAX(IF(EXTRACT(YEAR FROM trunc_month)=2024 AND EXTRACT(MONTH FROM trunc_month)=4, total_distinct_users, NULL)) AS April_2024,
MAX(IF(EXTRACT(YEAR FROM trunc_month)=2024 AND EXTRACT(MONTH FROM trunc_month)=5, total_distinct_users, NULL)) AS May_2024,
MAX(IF(EXTRACT(YEAR FROM trunc_month)=2024 AND EXTRACT(MONTH FROM trunc_month)=6, total_distinct_users, NULL)) AS June_2024,
MAX(IF(EXTRACT(YEAR FROM trunc_month)=2024 AND EXTRACT(MONTH FROM trunc_month)=7, total_distinct_users, NULL)) AS July_2024,
MAX(IF(EXTRACT(YEAR FROM trunc_month)=2024 AND EXTRACT(MONTH FROM trunc_month)=8, total_distinct_users, NULL)) AS August_2024,
MAX(IF(EXTRACT(YEAR FROM trunc_month)=2024 AND EXTRACT(MONTH FROM trunc_month)=9, total_distinct_users, NULL)) AS September_2024,
MAX(IF(EXTRACT(YEAR FROM trunc_month)=2024 AND EXTRACT(MONTH FROM trunc_month)=10, total_distinct_users, NULL)) AS October_2024,
MAX(IF(EXTRACT(YEAR FROM trunc_month)=2024 AND EXTRACT(MONTH FROM trunc_month)=11, total_distinct_users, NULL)) AS November_2024,
MAX(IF(EXTRACT(YEAR FROM trunc_month)=2024 AND EXTRACT(MONTH FROM trunc_month)=12, total_distinct_users, NULL)) AS December_2024,
FROM
production_data.feb_2024_overall_feature_usage
GROUP BY
section_name
order by section_name
How do I remove the columns with NULLS in all rows (i.e. the future months)?

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2014 Nancy France September 15 19 2014 Proceedings Part I Lnai 8724

Authors: Toon Calders ,Floriana Esposito ,Eyke Hullermeier ,Rosa Meo

2014th Edition

3662448475, 978-3662448472

More Books

Students also viewed these Databases questions

Question

a donor to the university or school?

Answered: 1 week ago