I have the following table in SQL Server:
Date Browser Country Time(ms)
----------------------------------------------------------
201
With conditional aggregation you already were on the right track for one possible solution. But have the condition on the country. In a WHERE
filter for the durations and stick the different durations together with UNION ALL
.
SELECT '0 - 1s' [Time(ms)],
count(CASE
WHEN [Country] = 'US' THEN
1
END) [US],
count(CASE
WHEN [Country] = 'JP' THEN
1
END) [JP]
FROM [dbo].[mytable]
WHERE [Time] >= 0
AND [Time] < 1000
UNION ALL
...
UNION ALL
SELECT '+3s' [Time(ms)],
count(CASE
WHEN [Country] = 'US' THEN
1
END) [US],
count(CASE
WHEN [Country] = 'JP' THEN
1
END) [JP]
FROM [dbo].[mytable]
WHERE [Time] >= 3000;