SELECT grade,
COUNT( DISTINCT CASE WHEN DATE '2015-01-01' >= date_column
AND date_column < DATE '2016-01-01'
THEN customer_id END
) AS number_of_unique_customers_in_2015,
COUNT( DISTINCT CASE WHEN DATE '2016-01-01' >= date_column
AND date_column < DATE '2017-01-01'
THEN customer_id END
) AS number_of_unique_customers_in_2016
FROM Customers
WHERE Date_Column >= DATE '2015-01-01'
AND Date_Column < DATE '2017-01-01'
GROUP BY grade;
2
solved Show columns of current year and previous year in oracle