For some people it might look very simple, but I just simply can\'t get it.
I have multiple MS-SQL SELECT queries from the same table over and over:
SELECT sum(case when Page LIKE '%AEC%' then 1 end) as tAEC,
sum(case when Page LIKE '%TOL%' then 1 end) as tTOL
FROM someTable
You can use a GROUP BY Page
SELECT
Page
, COUNT(Page) as "nb"
FROM someTable
GROUP BY Page
You can also do a GROUP BY CASE...
SELECT
CASE
WHEN Page LIKE '%AEC%' THEN "AEC"
WHEN Page LIKE '%TOL%' THEN "TOL"
ELSE ""
END AS "type"
, count(Page) as "nb"
FROM someTable
GROUP BY type
You can also COUNT IF
SELECT
COUNT(IF(Page LIKE '%AEC%', 1, NULL) THEN "AEC"
, COUNT(IF(Page LIKE '%TOL%', 1, NULL) THEN "TOL"
FROM someTable