MySQL - Using COUNT(*) in the WHERE clause

前端 未结 9 1703
不思量自难忘°
不思量自难忘° 2020-11-28 20:55

I am trying to accomplish the following in MySQL (see pseudo code)

SELECT DISTINCT gid
FROM `gd`
WHERE COUNT(*) > 10
ORDER BY lastupdated DES         


        
9条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-28 21:50

    -- searching for weather stations with missing half-hourly records

    SELECT stationid
    FROM weather_data 
    WHERE  `Timestamp` LIKE '2011-11-15 %'  AND 
    stationid IN (SELECT `ID` FROM `weather_stations`)
    GROUP BY stationid 
    HAVING COUNT(*) != 48;
    

    -- variation of yapiskan with a where .. in .. select

提交回复
热议问题