Answer the question
In order to leave comments, you need to log in
How to combine multiple requests into one?
There is a database with positions of search requests. Now we have to write a separate request for each of the cities and get the necessary data. Request example:
SELECT Query AS "Ключевая фраза",
SUM(CASE Updated WHEN '2021-05-20' THEN Yandex ELSE 0 END) AS "Я 2021-05-20 Екб"
FROM Queries c LEFT JOIN
SitePositions o ON c.Id = o.QueryId
WHERE SiteId = 33 AND RegionCode = 54
GROUP BY QueryId
SELECT Query AS "Ключевая фраза",
SUM(CASE Updated WHEN '2021-05-20' THEN Yandex ELSE 0 END) AS "Я 2021-05-20 Воронеж"
FROM Queries c LEFT JOIN
SitePositions o ON c.Id = o.QueryId
WHERE SiteId = 33 AND RegionCode = 193
GROUP BY QueryId
Answer the question
In order to leave comments, you need to log in
SELECT
Query AS "Ключевая фраза",
SUM(CASE WHEN (Updated = '2021-05-20' AND RegionCode = 54) THEN Yandex ELSE 0 END) AS "Yandex ekb",
SUM(CASE WHEN (Updated = '2021-05-20' AND RegionCode = 193) THEN Yandex ELSE 0 END) AS "Yandex vor"
FROM Queries c
LEFT JOIN SitePositions o ON c.Id = o.QueryId
WHERE SiteId = 33
GROUP BY QueryId, Query;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question