Where子句中的Postgresql数组

时间:2017-05-05 18:13:12

标签: postgresql

我正在尝试使用每个“date(t1.starttime)”只有一行的数组子句进行过滤。当前返回为数组中的每个项创建一行。这可能吗?我尝试在t1.starttime上选择distinct,但这只是从第一个t3.store返回结果。

SELECT
t2.name,
date (t1.starttime),
Count(t1.starttime) as "# Plays",
Count(distinct(t1.playerid)) as "# Stores"

FROM
public.billing t1 JOIN public.medias t2 on t1.mediaitemid = t2.id 
JOIN public.players t3 on t1.playerid = t3.id 

WHERE
t3.store in  ('0038','3285') and
t2.name LIKE any (array['COMM_7032%']) and
t1.starttime >= date('2017-04-26') and 
t1.starttime < date('2017-05-01') and
t1.channelname = 'myNetwork'

GROUP BY
date (t1.starttime),
t2.name,
t1.playerid,

ORDER BY
date (t1.starttime)

Returned Data...
"COMM_7032";"2017-04-27";20;1
"COMM_7032";"2017-04-27";20;1
"COMM_7032";"2017-04-28";34;1
"COMM_7032";"2017-04-28";34;1
"COMM_7032";"2017-04-29";35;1
"COMM_7032";"2017-04-29";35;1
"COMM_7032";"2017-04-30";21;1
"COMM_7032";"2017-04-30";22;1

尝试合并日期,以便读取此内容......

"COMM_7032";"2017-04-27";40;2 
"COMM_7032";"2017-04-28";68;2 
"COMM_7032";"2017-04-29";70;2 
"COMM_7032";"2017-04-30";43;2

0 个答案:

没有答案