我是SQL的新手,正在尝试制作我的第一个数据透视表。下面的代码产生错误 NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_calendar)
.setContentTitle("My Firebase Push notification")
.setContentText(message)
.setAutoCancel(true)
.setSound(soundUri)
.setContentIntent(pendingIntent);
。任何帮助将非常感激!我肯定在犯一些基本的语法错误,但终生找不到。
.setAutoCancel(true)
下面是当子查询自行运行时从syntax error at or near "PIVOT"
返回的示例数据
SELECT p.SO, p.FR, p.SR, p.JR
FROM
(SELECT players.year AS year
FROM benn.college_football_players players) sub
PIVOT
(
COUNT(sub.year) FOR sub.year IN ([SO], [FR], [SR], [JR])
)
AS p
答案 0 :(得分:2)
如果您不接受PIVOT
命令。我会使用条件 aggregate函数将CASE WHEN
与COUNT
一起使用。
例如,mysql不支持 PIVOT 命令,但是您可以使用聚合函数执行 PIVOT
CREATE TABLE college_football_players(
Year varchar(50)
);
insert into college_football_players values ('JR');
insert into college_football_players values ('SO');
insert into college_football_players values ('SO');
insert into college_football_players values ('FR');
insert into college_football_players values ('SR');
insert into college_football_players values ('JR');
查询1 :
SELECT COUNT(CASE WHEN year = 'SO' then 1 end) SO,
COUNT(CASE WHEN year = 'FR' then 1 end) FR,
COUNT(CASE WHEN year = 'SR' then 1 end) SR,
COUNT(CASE WHEN year = 'JR' then 1 end) JR
FROM benn.college_football_players players players
Results :
| SO | FR | SR | JR |
|----|----|----|----|
| 2 | 1 | 1 | 2 |
答案 1 :(得分:0)
问题不是代码,而是我在MODE Analytics SQL教程website上运行代码。该网站似乎不接受com.liferay.portlet.requires-namespaced-parameters=false
命令。