1. Delete the repeated records, not include Identity Increment ID (Col0)
DELETE FROM Table
WHERE Col0 NOT IN(
SELECT MIN(Col0)
FROM Table
GROUP BY Col1,Col2,Col3,Col4,Col5
)
2. Get all students' score
SELECT StuID,StuName,
MAX(CASE WHEN ClassName='Math' THEN Score END) AS Math,
MAX(CASE WHEN ClassName='Chinese' THEN Score END) AS Chinese,
MAX(CASE WHEN ClassName='English' THEN Score END) AS English
FROM T
GROUP BY StuID,StuName
浙公网安备 33010602011771号