SELECT
FirstName + '_count' AS firstName,
COUNT(distinct FirstName) AS Count1
FROM
test1(nolock)
GROUP BY
FirstName
结果即将出现:
firstName Count1
-------------------------------------------------------- -----------
Bruce_count 1
Haley_count 1
Madeline_count 1
Marshall_count 1
Sophia_count 1
(5 row(s) affected)
我需要它
firstName Count1
-------------------------------------------------------- -----------
Bruce_count Haley_count Madeline_count Marshall_count Sophia_count
1 1 1 1 1 1 <br/>
(5 row(s) affected)