1,等效于sql left join的LINQ语法:
2,
# 分组 求数量 SELECT Column1 ,COUNT(*) AS aCount FROM ( SELECT * FROM tableName ) AS T1 GROUP BY Column1 #要和上面的Column1 一样
ORDER BY aCount DESC ;
SELECT code,StartTime,EndTime ,COUNT(DISTINCT StartTime) as Count FROM ( SELECT * FROM tablename WHERE projectTypeName = '道路' AND StartTime >= '2021-07-05 00:00:00' AND EndTime <= '2021-07-05 23:59:59' AND TimeType = 1 GROUP BY Code,StartTime,EndTime ORDER BY code DESC ) AS T GROUP BY code ORDER BY Count DESC;