我有两张桌子。
我想在生日那天得到重复的学生,但我不知道如何获得重复的记录。我是sql的新手。我试过这个问题:
SELECT T.GivenName + ' ' + T.SurName AS Name,
T.StreetNumber + ' ' + T.StreetName + ' ' + T.Suburb + ' ' + T.PostCode + ' ' + T.State + ' ' + T.Country AS Address,
T.Sex,
T.DateOfBirth,
T.yearlevel AS Year,
z.dupCount,
T.StudentNumber
FROM tblMasterStudent AS T
INNER JOIN (SELECT DateOfBirth, COUNT(*) AS dupCount
FROM tblMasterStudent
GROUP BY DateOfBirth
HAVING (COUNT(*) > 1)) AS z ON z.DateOfBirth = T.DateOfBirth
ORDER BY z.dupCount DESC
它是从MasterStudent表中获取生日的重复记录,但我想从masterStudent + BoardingPoint获取记录
答案 0 :(得分:0)
您可以按生日分组并查看多次出现的所有生日:
SELECT count(1) as frequency, dob
FROM students
GROUP BY dob
HAVING frequency > 1;