sql server - 使结果垂直于水平

时间:2016-03-02 14:38:44

标签: sql sql-server sql-server-2008 sql-server-2012 database-administration

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)

0 个答案:

没有答案