gpt4 book ai didi

sql - '--and' 在 postgresql 查询中意味着什么

转载 作者:行者123 更新时间:2023-11-29 11:55:01 24 4
gpt4 key购买 nike

我继承了下面的查询,我想弄清楚第一个左连接中的“--and”是什么意思?使用 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' )

最佳答案

-- 是 C 或 C# 的 // 的 SQL 等价物。这意味着该行的其余部分已被注释。

关于sql - '--and' 在 postgresql 查询中意味着什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42930233/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com