My data table is as below:
ID WEEK RESULT 1 13 GOOD 2 13 BAD 3 13 GOOD 4 14 GOOD 5 14 BAD 6 15 BAD
I nee
You can use an aggregate function with a CASE expression to convert the rows into columns:
CASE
select week, sum(case when result = 'good' then 1 else 0 end) GoodResult, sum(case when result = 'bad' then 1 else 0 end) BadResult from yt group by week;
See SQL Fiddle with Demo