使用'like'子句进行大查询内连接

时间:2016-12-19 07:56:29

标签: sql google-bigquery

我在下面的大查询中有两个表是每个\

的图像表示

enter image description here

我想要的是通过对相应的Land URL进行分组来总计点击次数。下面是我正在使用的查询,但它没有返回任何结果

Select a.quarters as Quarters, sum(b.clicks) as Clicks
from `spreadsheetapi-1147.FlosportsDatabase.GroupByColumnReference` as a 
inner join `spreadsheetapi-1147.FlosportsDatabase.kenshoo` as b 
on lower(a.quarters) like concat('%' , b.land_url , '%' )
group by a.quarters

1 个答案:

答案 0 :(得分:3)

切换lower(a.quarters)b.land_url进行LIKE检查

Select a.quarters as Quarters, sum(b.clicks) as Clicks
from `spreadsheetapi-1147.FlosportsDatabase.GroupByColumnReference` as a 
inner join `spreadsheetapi-1147.FlosportsDatabase.kenshoo` as b 
on b.land_url like concat('%' , lower(a.quarters) , '%' )
group by a.quarters