0
按星期查詢的我的SQL組如下所示,但是在那裏出現跟隨錯誤。按星期查詢獲取錯誤組
列'timesheet.timeheet_date'在選擇列表中無效,因爲它不包含在聚合函數或GROUP BY子句中。
任何人可以幫助我在這方面
我的查詢:
select
DatePart(week, timesheet_date),
count(timesheet.timesheet_id) as TimeSheetID,
timesheet.timesheet_date,
timesheet.start_time,
timesheet.end_time,
timesheet.timesheet_status_id,
timesheet.is_deleted,
timesheet.created_by,
timesheet.modified_by,
timesheet.created_date,
task.name,
project.name,
[user].first_name, [user].last_name
from
timesheet, task, project, [user]
where
task_id = (select task_id from project_task
where project_task_id = timesheet.project_task_id)
and project_id = (select project_id from project_task
where project_task_id = timesheet.project_task_id)
and [user].user_id = timesheet.user_id
and timesheet.user_id = 30
group by
timesheet.timesheet_id
是否使用的是RDBMS? –
你有沒有試過找出錯誤信息試圖告訴你什麼?這是一個非常明確的信息。 – Tomalak
@astander這就是SQL Server。 – Tomalak