Answer the question
In order to leave comments, you need to log in
How to remove doubles in output?
Hello. I have a table that stores records of turning on and off all devices. During the day, the device may turn on and off several times. I need to display the number of devices that were turned off per day during the week. The table has the following structure: id, name, ip, type, time, status
I made a query like this:
SELECT COUNT(id) AS amount, time, status FROM info WHERE time > DATE_SUB(NOW(), INTERVAL 7 DAY) AND status = :status GROUP BY EXTRACT(DAY FROM time) ORDER BY time
Answer the question
In order to leave comments, you need to log in
SELECT COUNT(DISTINCT id) ... --подсчет всех уникальных значений. Чтобы убедиться, что все корректно, сначала запросите
SELECT DISTINCT id ... -- с вашим условием
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question