I'm currently running the following statement that is used in a Crystal
Report. Basically, a record is returned when the T_PAYMENT.amoun t
has a record in the database based on the value of the T_MULTILIST.cod e
field. Currently, if there is no record returned, there is no listing
in the report for the given T_MULTILIST.cod e.
The user now wants a record to be displayed on the report when there is
no record in the database - she wants it to display a value of '$0'
for the given T_MULTILIST.cod e record. I tried to explain the fact that
is not possible the way things stand at the moment. Basically I need
some type
of case statement that says 'if there is no record returned, create a
single record and set T_PAYMENT.amoun t = 0' AFTER each query has been
executed.
Anyone have any idea how to accomplish this?
SELECT DISTINCT
'English Language Arts, Grade 1' as Rec_Type, 'English Language Arts
(Consumable)' as Super_Type, '' as Other_Type, 'Continuing Contracts'
as Proc_Type,
T_MULTILIST_GRA DE.grade, T_MULTILIST.des cription, T_MULTILIST.cod e,
T_PAYMENT.amoun t
FROM (T_MULTILIST T_MULTILIST INNER JOIN (T_PAYMENT T_PAYMENT
INNER JOIN T_SHIPPING_DETA IL
T_SHIPPING_DETA IL ON
T_PAYMENT.trans action_id=T_SHI PPING_DETAIL.tr ansaction_id)
ON T_MULTILIST.cod e=T_SHIPPING_DE TAIL.multilist_ code) INNER JOIN
T_MULTILIST_GRA DE T_MULTILIST_GRA DE ON
T_MULTILIST.cod e=T_MULTILIST_G RADE.multilist_ code,
T_ORDER, T_REQUISITION, T_REQUISITION_D ETAIL
WHERE
T_ORDER.id = T_SHIPPING_DETA IL.order_id AND
T_REQUISITION.i d = T_ORDER.requisi tion_id AND
T_REQUISITION_D ETAIL.requisiti on_id = T_REQUISITION.i d AND
T_REQUISITION_D ETAIL.latest_re cord_flag = 1 AND
T_REQUISITION.l atest_record_fl ag = 1 AND
T_ORDER.latest_ record_flag = 1
AND (T_MULTILIST.co de='1040')
AND (T_MULTILIST.ex piration_year >= '2006' )
AND (T_REQUISITION. requested_shipm ent_date >= '2006' + '0601'
AND T_REQUISITION.r equested_shipme nt_date < dateadd(YY, 1,
'2006' + '0601' ) )
UNION
SELECT DISTINCT
'English Language Arts, Kindergarten' as Rec_Type, 'English
Language Arts (Consumable)' as Super_Type,
'' as Other_Type, 'Continuing Contracts' as Proc_Type,
T_MULTILIST_GRA DE.grade, T_MULTILIST.des cription,
T_MULTILIST.cod e, T_PAYMENT.amoun t
FROM (T_MULTILIST T_MULTILIST INNER JOIN (T_PAYMENT T_PAYMENT
INNER JOIN T_SHIPPING_DETA IL T_SHIPPING_DETA IL
ON T_PAYMENT.trans action_id=T_SHI PPING_DETAIL.tr ansaction_id)
ON T_MULTILIST.cod e=T_SHIPPING_DE TAIL.multilist_ code) INNER JOIN
T_MULTILIST_GRA DE T_MULTILIST_GRA DE ON
T_MULTILIST.cod e=T_MULTILIST_G RADE.multilist_ code,
T_ORDER, T_REQUISITION, T_REQUISITION_D ETAIL
WHERE
T_ORDER.id = T_SHIPPING_DETA IL.order_id AND
T_REQUISITION.i d = T_ORDER.requisi tion_id AND
T_REQUISITION_D ETAIL.requisiti on_id = T_REQUISITION.i d AND
T_REQUISITION_D ETAIL.latest_re cord_flag = 1 AND
T_REQUISITION.l atest_record_fl ag = 1 AND
T_ORDER.latest_ record_flag = 1
AND (T_MULTILIST.co de='0040')
and (T_MULTILIST.ex piration_year >= '2006' )
AND (T_REQUISITION. requested_shipm ent_date >= '2006' + '0601'
AND T_REQUISITION.r equested_shipme nt_date < dateadd(YY, 1,
'2006' + '0601' ) )
Up to 40 more UNION statements follow the above 2.