clear markdown compare help best fiddles feedback
clear markdown feedback
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0. 3601421 fiddles created (47999 in the last week).

select version();
version()
8.0.27
 hidden batch(es)


create table t (customer varchar(20), total_count INT, month varchar(20)); insert into t values ('ABC', 10, 'January'), ('ABC', 12, 'February'), ('ABC', 11, 'March'), ('DEF', 16, 'January'), ('DEF', 11, 'February'), ('DEF', 19, 'August'), ('XYZ', 99, 'December');
 hidden batch(es)


select * from t
customer total_count month
ABC 10 January
ABC 12 February
ABC 11 March
DEF 16 January
DEF 11 February
DEF 19 August
XYZ 99 December
 hidden batch(es)


SELECT customer, MAX(CASE WHEN month='January' THEN total_count ELSE 0 END) AS Jan, MAX(CASE WHEN month='February' THEN total_count ELSE 0 END) AS Feb, MAX(CASE WHEN month='March' THEN total_count ELSE 0 END) AS Mar, MAX(CASE WHEN month='April' THEN total_count ELSE 0 END) AS Apr, MAX(CASE WHEN month='May' THEN total_count ELSE 0 END) AS May, MAX(CASE WHEN month='June' THEN total_count ELSE 0 END) AS Jun, MAX(CASE WHEN month='July' THEN total_count ELSE 0 END) AS Jul, MAX(CASE WHEN month='August' THEN total_count ELSE 0 END) AS Aug, MAX(CASE WHEN month='September' THEN total_count ELSE 0 END) AS Sep, MAX(CASE WHEN month='October' THEN total_count ELSE 0 END) AS Oct, MAX(CASE WHEN month='November' THEN total_count ELSE 0 END) AS Nov, MAX(CASE WHEN month='December' THEN total_count ELSE 0 END) AS Decem FROM t GROUP BY customer
customer Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Decem
ABC 10 12 11 0 0 0 0 0 0 0 0 0
DEF 16 11 0 0 0 0 0 19 0 0 0 0
XYZ 0 0 0 0 0 0 0 0 0 0 0 99
 hidden batch(es)