我想算滿足此查詢條件的行數:如何計算分組記錄?
Select DISTINCT(projects.project_id)
, projects.project_name
, CONVERT(char(11), projects.kickoff_date, 102) AS kickoff_date
, status_phase.status_name
, eal.eal_abbrv
, tech_types.tech_name
from projects
INNER JOIN tech_assigned
ON projects.project_id = tech_assigned.project_id
INNER JOIN tech_types
ON tech_assigned.tech_id = tech_types.tech_id
inner join status_phase
on projects.status_phase_id=status_phase.status_phase_id
inner join eal
on projects.eal_id=eal.eal_id
where status_phase.status_id <= 2
order by eal.eal_abbrv
我想通過eal.eal_name列分組計數,但是當我嘗試這樣做,我得到了可怕的「列'projects.project_id'
在選擇列表中無效,因爲它不包含在聚合函數或GROUP BY子句中。「錯誤信息。我可以通過使用Select COUNT(*)
或COUNT(1)
函數來計數記錄,但我需要在組內計數。
查詢中沒有提到'eal_name'。其次,你爲什麼要做一個「獨特」的。 。 。連接產生太多的行? –
是eal.eal_name唯一嗎? – Sebas