I need join two queries for output only, it's possible?... I tried with syntax CASE WHEN but I fail... can you help me?thank you.

SELECT
sum(visitorcount) AS total
FROM
tbl_session;
SELECT
SUM(visitorcount) AS tot_CURRENT_MONTH,
MONTH (visitdate) AS MONTH
FROM
tbl_session
WHERE
MONTH (visitdate) = MONTH (CURRENT_DATE())
AND YEAR (visitdate) = YEAR (CURRENT_DATE())
GROUP BY
MONTH (visitdate);

cms9651
—
2012-12-31T10:30:20Z —
#2

this solution working, it's correct?

SELECT
SUM(
CASE
WHEN visitorcount THEN
visitorcount
END
) AS total,
SUM(
CASE
WHEN MONTH (visitdate) = MONTH (CURRENT_DATE())
AND YEAR (visitdate) = YEAR (CURRENT_DATE()) THEN
visitorcount
END
) AS tot_CURRENT_MONTH
FROM
tbl_session;

guido2004
—
2012-12-31T11:37:09Z —
#3

You don't need the CASE in the first SUM, and I'd put an ELSE 0 in the second CASE:

SELECT
SUM(visitorcount) AS total
, SUM(
CASE
WHEN MONTH (visitdate) = MONTH (CURRENT_DATE()) AND
YEAR (visitdate) = YEAR (CURRENT_DATE())
THEN visitorcount
ELSE 0
END
) AS tot_CURRENT_MONTH
FROM
tbl_session;