Answer the question
In order to leave comments, you need to log in
How to find the number of rows in a SQL query with JOIN?
The request is the following:
SELECT leads.*, sites.NAME_SITE
FROM `leads` leads
LEFT JOIN `sites` sites ON sites.SOURCE_ID = leads.SOURCE_ID
WHERE
leads.PHONE != "9 (999) 999 99-99" AND
leads.NAME != "тест" AND
leads.SOURCE_ID IN (1,3,4,5,6,7,8,10,11,12,14,15) AND
`DATE_CREATE` BETWEEN "2020-06-01" AND "2020-06-30"
GROUP BY leads.PHONE ORDER BY DATE_CREATE DESC
Answer the question
In order to leave comments, you need to log in
SELECT COUNT(DISTINCT `leads`.`PHONE`)
FROM `leads`
LEFT JOIN `sites` ON `sites`.`SOURCE_ID` = `leads`.`SOURCE_ID`
WHERE `leads`.`PHONE` != '9 (999) 999 99-99'
AND `leads`.`NAME` != 'тест'
AND `leads`.`SOURCE_ID` IN (1,3,4,5,6,7,8,10,11,12,14,15)
AND `DATE_CREATE` BETWEEN '2020-06-01' AND '2020-06-30'
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question