1

海外の同僚から sql ステートメントを受け取ったのですが、実行しようとすると "Enter Substitution Variable" というボックスが表示されます。何を入れますか?私の同僚は、彼らは同じ箱を手に入れないと言います. このメッセージの原因は何ですか? 私は以下の声明を提供しています。どんな助けでも大歓迎です。

また、3 行目では、右括弧が欠落しているというメッセージが表示されます。

select SUBSTR(created_ts, 1, 7) as created_month, 
count(t1.id) as mops_created,
count(completed_ts <> '') as num_complete,
round(AVG(DATEDIFF(planning_complete_ts, created_ts)), 1) as average_created_to_planning_complete,
round(AVG(DATEDIFF(review_complete_ts, planning_complete_ts)), 1) as average_planning_complete_to_review_complete,
round(AVG(DATEDIFF(scheduling_complete_ts, planning_complete_ts)), 1) as average_planning_complete_to_scheduling_complete,
round(AVG(DATEDIFF(scheduled_ts, scheduling_complete_ts)), 1) as average_scheduled_for_x_days_out,
round(AVG(DATEDIFF(completed_ts, planning_complete_ts)), 1) as average_planning_complete_to_mop_complete,
round(AVG(planning_complete_num), 1) as average_num_times_planning_complete,
max(planning_complete_num) as max_planning_complete,
round(AVG(scheduling_complete_num), 1) as average_num_time_scheduled,
max(scheduling_complete_num) as max_scheduled_num
FROM
(select a.id, a.created_ts, a.scheduled_ts, work_start_ts, completed_ts
from TRAFFIC_ENG.DSIS_CC_MASTER as a 
WHERE 
                a.created_ts >= '2013-01-01 00:00:00'
AND 
                a.status_cc_options_id NOT IN (810, 820)) as t1
LEFT JOIN
(select a.id, max(c.orig_date) as review_complete_ts 
from 
                TRAFFIC_ENG.DSIS_CC_MASTER as a
INNER JOIN
                TRAFFIC_ENG.DSIS_CC_LOG_NOTE as c
                ON c.cc_master_id = a.id
                AND (c.cc_log_note_type_id = 8 OR c.note = 'Passed Review & submitted to Scheduling')
WHERE 
                a.created_ts >= '2013-01-01 00:00:00'
AND 
                a.status_cc_options_id NOT IN (810, 820)
GROUP BY a.id) as review_complete
ON review_complete.id = t1.id
LEFT JOIN
(
select a.id, min(c.orig_date) as planning_complete_ts 
from 
                TRAFFIC_ENG.DSIS_CC_MASTER as a
INNER JOIN
                TRAFFIC_ENG.DSIS_CC_LOG_NOTE as c
                ON c.cc_master_id = a.id
                AND (c.cc_log_note_type_id = 5 OR c.note = 'Submitted for Review')
WHERE 
                a.created_ts >= '2013-01-01 00:00:00'
AND 
                a.status_cc_options_id NOT IN (810, 820)
GROUP BY a.id

) as planning_complete
ON planning_complete.id = t1.id
LEFT JOIN
(
select a.id, (c.orig_date) as scheduling_complete_ts 
from 
                TRAFFIC_ENG.DSIS_CC_MASTER as a
INNER JOIN
                TRAFFIC_ENG.DSIS_CC_LOG_NOTE as c
                ON c.cc_master_id = a.id
                AND (c.cc_log_note_type_id = 7 OR c.note='Scheduled')
WHERE 
                a.created_ts >= '2013-01-01 00:00:00'
AND 
                a.status_cc_options_id NOT IN (810, 820)
GROUP BY a.id
) as scheduling_complete
ON scheduling_complete.id = t1.id
LEFT JOIN
(
select a.id, count(c.orig_date) as planning_complete_num 
from 
                TRAFFIC_ENG.DSIS_CC_MASTER as a
INNER JOIN
                TRAFFIC_ENG.DSIS_CC_LOG_NOTE as c
                ON c.cc_master_id = a.id
                AND (c.cc_log_note_type_id = 5 OR c.note = 'Submitted for Review')
WHERE 
                a.created_ts >= '2013-01-01 00:00:00'
AND 
                a.status_cc_options_id NOT IN (810, 820)
GROUP BY a.id

) as planning_complete_num
ON planning_complete_num.id = t1.id
LEFT JOIN
(
select a.id, count(c.orig_date) as scheduling_complete_num
from 
                TRAFFIC_ENG.DSIS_CC_MASTER as a
INNER JOIN
                TRAFFIC_ENG.DSIS_CC_LOG_NOTE as c
                ON c.cc_master_id = a.id
                AND (c.cc_log_note_type_id = 7 OR c.note='Scheduled')
WHERE 
                a.created_ts >= '2013-01-01 00:00:00'
AND 
                a.status_cc_options_id NOT IN (810, 820)
GROUP BY a.id
) as scheduling_complete_num
ON scheduling_complete_num.id = t1.id

GROUP BY created_month
4

3 に答える 3

1

「Passed Review & submit to Scheduling」に & 記号が存在するのは、通常、その場所で変数を置換する必要があることを SQL ツールに示しているためです。

Toad のようなグラフィカル ツールを使用している場合は、View/Options/Prompt for Substitution Variables でこれをオフにすることができます。

于 2013-11-08T15:18:31.643 に答える