Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想要以“55”开头的列中的所有数字的总和,并希望将它们组合在 1 行中。因此,该列中以 55 开头的所有数字都应分组为 1 行。
SELECT SUM(Column_NAME), SUBSTRING(CAST(COLUMN_NAME AS VARCHAR(MAX)), 0, 2) FROM TABLE GROUP BY SUM(Column_NAME), SUBSTRING(CAST(COLUMN_NAME AS VARCHAR(MAX)), 0, 2)