1
以下任何幫助將非常感謝;如何在加入多個表後刪除sql查詢結果中的重複記錄
使用以下腳本加入多個表以收集我需要的信息後,現在結果中有多個重複記錄。
我無法使用截然不同,所以在導出之前如何擺脫select語句中的重複結果?
use Cohort
select *
from patients
join immunisations
on patients.patient_id = immunisations.patient_id
join titles
on patients.title_id = titles.title_id
join courses
on immunisations.course_id = courses.course_id
join departments
on patients.patient_id = departments.department_id
join employees
on patients.patient_id = employees.post_title_id
問候
路易絲
不同,因爲你使用的是行不通的*。您需要指定要保留的列並再次嘗試清除。 –
在發佈問題之前,您需要閱讀SQL基礎知識。瞭解如何使用GROUP BY子句:https://docs.microsoft.com/en-us/sql/t-sql/queries/select-group-by-transact-sql – Tanner
可能的重複[如何使用T-SQL Group By](https://stackoverflow.com/questions/2702/how-do-i-use-t-sql-group-by) – Tanner