我继承了下面的查询,我试图找出" - 和"意味着在第一个左连接?使用8.1。
我的任务是限制Origination的结果>一个约会,首先只想弄清楚它为什么会起作用......
select distribution_stop_information.customer_no,
distribution_line_items.item_number,
distribution_line_items.container_id,
distribution_line_items.item_description,
distribution_stop_information.customer_reference,
distribution_stop_information.bol_number, SUBSTRING(distribution_stop_information.bol_number,1,4) as ODDC,
SUBSTRING(distribution_stop_information.bol_number,9,4) as ODRT,
distribution_stop_information.branch_id,
distribution_stop_information.route_date,
(select count(innerDLI.item_number)-1 from distribution_line_items innerDLI where innerDLI.item_number = distribution_line_items.item_number) as RDLcount,
(select innerDLI.datetime_created from distribution_line_items innerDLI where innerDLI.item_number = distribution_line_items.item_number order by innerDLI.datetime_created asc limit 1) as Origination,
distribution_stop_information.route_code,
distribution_stop_information.stop_name,
distribution_stop_information.stop_address,
distribution_stop_information.stop_city,
distribution_stop_information.stop_state,
distribution_stop_information.stop_zip_postal_code,
distribution_stop_information.stop_signature,
CASE WHEN distribution_line_items.exception_code is not null
THEN distribution_line_items.exception_code
ELSE distribution_stop_information.stop_exception_code
END as ExceptionCode,
distribution_stop_information.signature_file_name,
distribution_stop_information.sign_bitmap_file_exists,
ScanR.item_was_scanned as ScanR,
ScanL.item_was_scanned as ScanL,
ScanD.item_was_scanned as ScanD
from distribution_stop_information
inner join distribution_line_items on distribution_line_items.unique_id_no = distribution_stop_information.unique_id_no
left join distribution_item_scans ScanR on
ScanR.item_sequence_no = distribution_line_items.item_sequence_no
and ScanR.stop_unique_id_no = distribution_stop_information.unique_id_no and ScanR.scan_type = 1
--and ScanR.scan_datetime between to_date(?, 'YYYY-MM-DD') and ( to_date(?, 'YYYY-MM-DD') + interval '1 day' )
left join distribution_item_scans ScanL on
ScanL.item_sequence_no = distribution_line_items.item_sequence_no
and ScanL.stop_unique_id_no = distribution_stop_information.unique_id_no and ScanL.scan_type = 2
and ScanL.scan_datetime between to_date(?, 'YYYY-MM-DD') and ( to_date(?, 'YYYY-MM-DD') + interval '1 day' )
left join distribution_item_scans ScanD on
ScanD.item_sequence_no = distribution_line_items.item_sequence_no
and ScanD.stop_unique_id_no = distribution_stop_information.unique_id_no and ScanD.scan_type = 9
and ScanD.scan_datetime between to_date(?, 'YYYY-MM-DD') and ( to_date(?, 'YYYY-MM-DD') + interval '1 day' )
where
distribution_stop_information.customer_no in ( '90202' )
and distribution_stop_information.route_date between ( to_date(?, 'YYYY-MM-DD') ) and ( to_date(?, 'YYYY-MM-DD') )
and distribution_line_items.datetime_created between ( to_date(?, 'YYYY-MM-DD') - interval '288 hours' ) and ( to_date(?, 'YYYY-MM-DD') + interval '12 hours' )
答案 0 :(得分:4)
--
是C或C#的//
的SQL等价物。这意味着该行的其余部分已被评论。
答案 1 :(得分:2)
--
表示已将其注释掉。它最初只是另一个AND
- 另一个用于连接的过滤器 - 但有人删除它而不想彻底删除代码。它没有效果。