0

如果我有一个刚刚返回的记录集:

SELECT * FROM USERS

    Name | Gender |   Company
    Bob  |  male  |  Abc Inc.
    Bob  |  male  |  Xyz Inc.
    Bob  |  male  |    NULL

我希望它返回这个:

    Name | Gender |   Company
    NULL |  NULL  |    NULL
    NULL |  NULL  |    Abc Inc.
    NULL |  male  |    NULL
    NULL |  male  |    Abc Inc.
    NULL |  NULL  |    Xyz Inc.
    NULL |  male  |    Xyz Inc.
    Bob  |  NULL  |    NULL
    Bob  |  NULL  |    Abc Inc.
    Bob  |  male  |    NULL
    Bob  |  male  |    Abc Inc.
    Bob  |  NULL  |    Xyz Inc.
    Bob  |  male  |    Xyz Inc.

它是如何实现的?

4

2 回答 2

1
select Name, Gender, Company
from T
group by Name, Gender, Company with cube
于 2012-04-15T18:47:21.487 回答
0
SELECT DISTINCT NAME, GENDER, COMPANY FROM TABLE
GROUP BY NAME, GENDER, COMPANY WITH CUBE
于 2012-04-15T18:56:16.777 回答