LEFT OUTER JOIN MATCHING

时间:2017-01-31 17:45:14

标签: sql-server join left-join

我有以下查询,我修改它以便能够查看名为Futuredial_Validation的新表,我写了所有的条件和连接但是它仍然没有查看表,只是在一个名为cellscripter的表中,查询的其余部分有效,我非常感谢任何帮助,谢谢:

SELECT row_number() OVER (ORDER BY wms_us.wms_us.rrno.rrdate, wms_us.wms_us.rrno.pono, wms_us.wms_us.transferboxdet.meidhex, att.Date_cleared) AS ROW_ID,
  wms_us.wms_us.rrno.pono                                                                                                                      AS ATT_PO,
  wms_us.wms_us.rrno.rrdate                                                                                                                    AS Received_Date,
  CASE
    WHEN (wms_us.wms_us.model.modeldesc = 'MIXED')
    THEN wms_us.wms_us.transferboxdet.basemodel
    ELSE wms_us.wms_us.model.modelbase
  END AS Model,
  CASE
    WHEN LEN(wms_us.wms_us.transferboxdet.meidhex) >= 15
    THEN LEFT(wms_us.wms_us.transferboxdet.meidhex, 14)
    ELSE wms_us.wms_us.transferboxdet.meidhex
  END AS IMEI,
  /*Check in Futerdial else obtain the values from cellscripter*/
  CASE
    WHEN (Future.[Error Code] = '1')
    THEN Future.LocalTime
    ELSE att.Date_cleared
  END AS Date_cleared,
  CASE
    WHEN (Future.[Error Code] = '1')
    THEN 'PASS'
    ELSE att.Result
  END AS Result
FROM wms_us.wms_us.transferboxdoc
INNER JOIN wms_us.wms_us.transferboxdet
ON wms_us.wms_us.transferboxdoc.transferboxdocid = wms_us.wms_us.transferboxdet.transferboxdocid
INNER JOIN wms_us.wms_us.rrno
ON wms_us.wms_us.transferboxdet.rrnoid = wms_us.wms_us.rrno.rrnoid
INNER JOIN wms_us.wms_us.model
ON wms_us.wms_us.transferboxdoc.modelid = wms_us.wms_us.model.modelid
LEFT OUTER JOIN Futerdial.dbo.Futuredial_Validation AS Future
ON Future.IMEI = LEFT(wms_us.wms_us.transferboxdet.meidhex, 14)
LEFT OUTER JOIN DRSCSQLQADB01.att_view2.dbo.attview2 AS att
ON att.IMEI                      = LEFT(wms_us.wms_us.transferboxdet.meidhex, 14)
WHERE (wms_us.wms_us.rrno.rrdate > '2016-12-01')

1 个答案:

答案 0 :(得分:0)

最有可能的情况是:您的加入规范无效或case的{​​{1}}表达式不正确。

检查您是否获得[Error Code][Future_imei]的任何值:

[Error Code]