【发布时间】:2015-03-27 11:24:57
【问题描述】:
我有这张桌子:
Player Routes Colors
GIN 2 RED
GIN 1 BLU
GIN 5 BLAS
GIN 1 TREN
GIN 2 RED
PON 1 TREN
PON 4 BLU
来自 union all 的查询,如下所示:
select *
from (
select DISTINCT Colors.Name [Colors]
, COUNT(routes.idRoutes) [Routes]
, Routes.cdRoutes [Doc]
from Routes
inner join Colors on Colors.Name blablabla
where blablabla
group by Colors.Name, Routes.cdRoutes
) dates
我需要一个这样的表来代替:
Colors GIN PON
RED 4 0
BLU 1 4
BLAS 5 0
TREN 1 1
怎么做?我想我可以不用 PIVOT 函数来获取它,对吧?
【问题讨论】:
标签: mysql sql sql-server tsql