我正在使用BigQuery在此处提取一些数据,但是每当我尝试添加“两次之间”时,我都不会以正确的方式收到信息。
有什么主意为什么不带给我这些价值?
SELECT
DISTINCT FECHA,
product_trademark,
VENTAS,
ORDENES,
USUARIOS,
main_grouped_store
FROM
DB
WHERE
product_trademark LIKE '%Kero-Coco%'
OR product_trademark LIKE '%kero-coco%'
AND COUNTRY = 'BR'
AND FECHA BETWEEN '201908' AND '201910'
ORDER BY
VENTAS
答案 0 :(得分:0)
假设FECHA字段是带有YYYYMM模式的STRING-最有可能是您的问题在于OR和AND的混合-因此请尝试以下
SELECT DISTINCT
FECHA,
product_trademark,
VENTAS,
ORDENES,
USUARIOS,
main_grouped_store
FROM DB
WHERE (product_trademark LIKE '%Kero-Coco%'
OR product_trademark LIKE '%kero-coco%')
AND COUNTRY = 'BR'
AND FECHA BETWEEN '201908' AND '201910'
ORDER BY VENTAS
作为一种选择-您可以像下面的示例一样将两个OR'ed条件折叠为一个条件
SELECT DISTINCT
FECHA,
product_trademark,
VENTAS,
ORDENES,
USUARIOS,
main_grouped_store
FROM DB
WHERE LOWER(product_trademark) LIKE '%kero-coco%'
AND COUNTRY = 'BR'
AND FECHA BETWEEN '201908' AND '201910'
ORDER BY VENTAS