Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I am attempting to load in data via a SQL connection. The connection is good and I can load in some queries, however, when I attempt to load in this query, the load is successful, however no data populates.
Is there an error in my script? Seems to get stuck after the 'SELECT' portion.
select
po.created_date, es.last_updated_date, e.event_code,
e.event_date, a.agency_code, bt.buyer_type_code, bt.description buyer_type_desc,
c.channel_code, c.description channel_desc, ps.price_scale_code,
ps.description price_scale_desc, es.price, sec.section_code, s.row_, s.seat_number
from
agency a, buyer_type bt, channel c, event e, event_category ec, event_seat es, order_line_item oli,
patron_order po, price_scale ps, seat s, section sec
where
oli.order_id = po.order_id
and oli.usage_event_id = e.event_id
and es.event_id = e.event_id
and es.order_id = po.order_id
and es.order_line_item_id = oli.order_line_item_id
and po.created_by_agency_id = a.agency_id
and a.channel_id = c.channel_id
and e.event_category_id = ec.event_category_id
and sec.section_id = es.section_id
and s.seat_id = es.seat_id
and es.buyer_type_id = bt.buyer_type_id
and ps.price_scale_id = es.price_scale_id
and trunc(po.created_date) >= ('01-JAN-2017')
and trunc(po.created_date) <= ('08-APR-2018')
and oli.market_type_code = 'P'
and oli.transaction_type_code in ( 'SA', 'ES', 'CS' ) -- sale, claimsale or exchangesale
and c.channel_code in ( 'BOXOFF', 'INTERNET', 'PHONE' )
and ec.event_category_code = 'HOCKEY'
and e.event_id >= '4461' and e.event_id <= '4502'
starts with a select count(*) of 2 tables, oli and po with the join
how many rows?
add the filters on oli and po
how many rows?
repeat: add one table, add one table, .....
Apologies, I am very new to SQL scripting. Can you explain what you mean?
I think you can start with 2 tables and check if you get a result
select count(*)
from
order_line_item oli,
patron_order po
where
oli.order_id = po.order_id
if you get a result (count > 0) add the filter (bold) on the 2 tables
select count(*)
from
order_line_item oli,
patron_order po
where
oli.order_id = po.order_id
and trunc(po.created_date) >= ('01-JAN-2017')
and trunc(po.created_date) <= ('08-APR-2018')
and oli.market_type_code = 'P'
and oli.transaction_type_code in ( 'SA', 'ES', 'CS' )
if you get a result add another table and the join with the previous 2 tables
maybe
table: agency a
join: and po.created_by_agency_id = a.agency_id
and so on until you have all the tables in the query; when you get 0 rows as result you should understand where is the problem
Thank you, I will attempt this