通过排除特定字符串的SQL筛选器

时间:2017-07-11 19:16:18

标签: sql oracle11g

我希望通过显示"DATA_POINT_UPLOAD_DATA"."VALUE"的最新值来运行我的查询(下方),'READY'除外。目前,它显示所有'READY'值,但是,我希望通过显示除'READY'之外的任何值来执行相反的操作。

这是我当前的查询:

select  "DATA_POINT_UPLOAD_DATA"."LAST_UPDATED_TIMESTAMP" as "TIMESTAMP",
               "DATA_POINT_UPLOAD_DATA"."VALUE" as "COMMENTS"
 from   "DB"."COMPONENT" "COMPONENT",
    "DB"."COMPONENT_DATA_POINT" "COMPONENT_DATA_POINT",
    "DB"."DATA_POINT_UPLOAD_DATA" "DATA_POINT_UPLOAD_DATA" 
 where   "COMPONENT_DATA_POINT"."ID"="DATA_POINT_UPLOAD_DATA"."COMPONENT_DATA_POINT_ID"
 and     "COMPONENT"."ID"="COMPONENT_DATA_POINT"."COMPONENT_ID"
  and    "DATA_POINT_UPLOAD_DATA"."VALUE" ='READY' 
   and   "DATA_POINT_UPLOAD_DATA"."LAST_UPDATED_TIMESTAMP" between ('01-JUN-17') and ('30-JUN-17') 
   and   "COMPONENT_DATA_POINT"."NAME" ='StateOfItem' 
   and   "COMPONENT"."SITE_ID" in('abc123');

非常感谢任何帮助。

3 个答案:

答案 0 :(得分:1)

在您的WHERE条款中,您拥有以下内容:"DATA_POINT_UPLOAD_DATA"."VALUE" ='READY'。这意味着您要显示DATA_POINT_UPLOAD_DATA值为'READY'的行。

更改您的查询,而不是使用=尝试使用!=<>

SELECT "DATA_POINT_UPLOAD_DATA"."LAST_UPDATED_TIMESTAMP" AS "TIMESTAMP",
  "DATA_POINT_UPLOAD_DATA"."VALUE"                       AS "COMMENTS"
FROM "DB"."COMPONENT" "COMPONENT",
  "DB"."COMPONENT_DATA_POINT" "COMPONENT_DATA_POINT",
  "DB"."DATA_POINT_UPLOAD_DATA" "DATA_POINT_UPLOAD_DATA"
WHERE "COMPONENT_DATA_POINT"."ID"    ="DATA_POINT_UPLOAD_DATA"."COMPONENT_DATA_POINT_ID"
AND "COMPONENT"."ID"                 ="COMPONENT_DATA_POINT"."COMPONENT_ID"
AND "DATA_POINT_UPLOAD_DATA"."VALUE" !='READY'
AND "DATA_POINT_UPLOAD_DATA"."LAST_UPDATED_TIMESTAMP" BETWEEN ('01-JUN-17') AND ('30-JUN-17')
AND "COMPONENT_DATA_POINT"."NAME" ='StateOfItem'
AND "COMPONENT"."SITE_ID"        IN('abc123');

答案 1 :(得分:0)

很抱歉,但这是一个可怕的查询。几乎只有大写以便最小化可读性,表别名不是别名,二十五年前冗余的连接语法,仅在某些语言设置中工作的日期字符串文字,以及不必要的连接。

然后您选择包含value = 'READY'的记录,并说明您希望'READY'的记录。好吧,那么:WHERE NOT value = 'READY'或只是WHERE value <> 'READY'

以下是更改的查询:

Select  
  last_updated_timestamp as "timestamp",
  value as comments
From db.data_point_upload_data
Where value <> 'READY' 
and last_updated_timestamp between '2017-06-01' and '2017-06-30'
and cdp_id in
(
  select id
  from db.component_data_point
  where name = 'StateOfItem'
  and component_id in (select id from db.component where site_id = 'abc123')
);

如果您只想查看最新的n行,请order by last_updated_timestamp desc limit <n>

答案 2 :(得分:0)

您现在要求每VALUE个最新记录。但是,您只选择LAST_UPDATED_TIMESTAMPLAST_UPDATED_TIMESTAMP。所以你问的只是VALUEMAX(last_updated_timestamp) GROUP BY value。在SQL中,这会转换为Select max(last_updated_timestamp) as "timestamp", value as comments From db.data_point_upload_data Where value <> 'READY' and last_updated_timestamp between '2017-06-01' and '2017-06-30' and cdp_id in ( select id from db.component_data_point where name = 'StateOfItem' and component_id in (select id from db.component where site_id = 'abc123') ) Group by value; SOME_CODE

input_layer = keras.layers.Input(
        (IMAGE_BORDER_LENGTH, IMAGE_BORDER_LENGTH, NB_CHANNELS))

current_layer = image_mirror_left_right(input_layer)

current_layer = keras.layers.convolutional.Conv2D(
      filters=16, "some values " ])
        )(current_layer)

def random_image_mirror_left_right(input_layer):
    return keras.layers.core.Lambda(function=lambda batch_imgs: tf.map_fn(
        lambda img: tf.image.random_flip_left_right(img), batch_imgs
    )
    )(input_layer)