The SQL SELECT DISTINCT Statement The SELECT DISTINCT statement is used to return only distinct (different) values. Inside a table, a column often contains many duplicate values; and sometimes you only want to list the different (distinct) values.
In Excel, there are several ways to filter for unique values—or remove duplicate values: To filter for unique values, click Data > Sort & Filter > Advanced. To remove duplicate values, click Data > Data Tools > Remove Duplicates.
To get unique or distinct values of a column in MySQL Table, use the following SQL Query. SELECT DISTINCT(column_name) FROM your_table_name; You can select distinct values for one or more columns.
I have a problem in my SQL Query
i want to select DISTINCT StudentGroups(SG) but the query gives me some repetations
here is my Query
SELECT DISTINCT(SG.SGID), en.EnrollmentID, CR.Name AS Course, INS.Name as Instructor,
S.Session, SG.StartTime, SG.EndTime, EN.CreateDate
FROM StudentGroups SG inner JOIN Enrollments EN ON SG.SGID = EN.SGID
JOIN Courses CR ON SG.CourseID = CR.CourseID
JOIN Class CL ON SG.ClassID = CL.ClassID
JOIN Instructors INS ON SG.InstructorID = INS.InstructorID
JOIN Sessions S ON SG.SessionID = S.SessionID
WHERE EN.SGID NOT IN ( SELECT SGID FROM Enrollments
WHERE StudentID = 45
UPDATED
This query gives me following data
but i don't want repeated SGID
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With