如何在GBQ SQL中设置WHERE筛选器,只显示列中为空的实例?

huangapple go评论56阅读模式
英文:

How to set WHERE filter to only show instances of a column where blank in GBQ SQL?

问题

我正在使用WHERE函数来筛选时间戳列为空的实例。

我正在处理的数据集在cancelled_datetime列中填充了日期,如果库存已交付。

我想仅显示供应商Walmart的数据,其中cancelled_datetime列没有数据。我该如何操作?

以下是我的脚本,但出现了错误消息:

{无法将字面量“”转换为TIMESTAMP}

我尝试过:

WHERE supplier_code = "Walmart" 
AND cancelled_datetime <> ""

我期望收到一个表,显示来自供应商Walmart的数据,不包括日期。

英文:

I am using the WHERE function to filter out instances where a column of timestamp is empty.

The data set I am working with populates a date in the column cancelled_datetime if stock is delivered.

I want to only show data of supplier Walmart where there is no data in the cancelled_datetime column. How do I go about doing so?

Below is my script that breaks with the error message:
>{Could not cast literal "" to type TIMESTAMP}

I tried:

WHERE supplier_code = &quot;Walmart&quot; 
AND cancelled_datetime &lt;&gt; &quot;&quot;

I was expecting to receive a table indicating data from supplier Walmart that does not include a date.

答案1

得分: 0

错误消息表明cancelled_datetime列是一个时间戳类型,它可以是有效的时间戳或NULL值。根据您的需求,您可以使用IS NULL筛选条件来获取您想要的结果。

以下是查询:

WHERE supplier_code = "Walmart" 
AND cancelled_datetime IS NULL
英文:

The error message suggests that cancelled_datetime column is a timestamp type, which it will be either a valid timestamp or a NULL value. For what you are looking for, you can use IS NULL filter to get the result you want.

Here is the query:

WHERE supplier_code = &quot;Walmart&quot; 
AND cancelled_datetime IS NULL

huangapple
  • 本文由 发表于 2023年3月15日 19:18:17
  • 转载请务必保留本文链接:https://go.coder-hub.com/75743993.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定