一個表中的id有多個記錄,把所有這個id的記錄查出來,並顯示共有多少條記錄數
select id ,Count(*) from table_name group by id having count(*)>1
給出一張表
查詢數學成績相同的記錄,並顯示出該成績相同記錄數
SELECT Math,COUNT(*) from [TestDB].[dbo].[Student] group by Math having COUNT(*)>1;
結果
select id ,Count(*) from table_name group by id having count(*)>1
查詢數學成績相同的記錄,並顯示出該成績相同記錄數
SELECT Math,COUNT(*) from [TestDB].[dbo].[Student] group by Math having COUNT(*)>1;
本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。