Skip to main content
Question

Writing conditional values into SQL Creator

  • October 25, 2017
  • 1 reply
  • 7 views

Forum|alt.badge.img

Hello,

I'm not sure whether this is possible or not. I've created an SQLCreator with the following SQL, the objective is to return all records from the table 'TableA' that do not join on 'equip_no' in 'TableC' because the attribute name 'SERIALNUMBER' is not available.

SELECT m.EQUIP_NO,m.EQUIP_GRP_ID,EQUIP_CLASS,PLANT_NO,a.TABLE_DESC as "ROUTE",b.TABLE_DESC as "DELIVERY UNIT",c.TABLE_DESC as "ENGINEER",d.TABLE_DESC as "SECTION MANAGER"
FROM TABLEA m
LEFT JOIN TABLEB a on m.EQUIP_CLASSIFX2=a.TABLE_CODE and a.TABLE_TYPE='E1'
LEFT JOIN TABLEB b on m.EQUIP_CLASSIFX11=b.TABLE_CODE and b.TABLE_TYPE='E10'
LEFT JOIN TABLEB c on m.EQUIP_CLASSIFX13=c.TABLE_CODE and c.TABLE_TYPE='E12'
LEFT JOIN TABLEB d on m.EQUIP_CLASSIFX16=d.TABLE_CODE and d.TABLE_TYPE='E15'
LEFT JOIN TABLEC e ON m.equip_no=e.equip_no and e.ATTRIBUTE_NAME='SERIALNUMBER'
where
(e.equip_no is null and m.EQUIP_GRP_ID='AU190RTK0001' and m.DSTRCT_CODE='RTK1')
or
(e.equip_no is null and m.EQUIP_GRP_ID='AU190RTK0002' and m.DSTRCT_CODE='RTK1')

The SQL does work successfully, however I have no way of identifying the attribute that is missing. I'm hoping it is possible that I can write the name of the missing attribute (e.g 'SERIALNUMBER') into the SQL query itself so that I can identify it.

I appreciate I could use an AttributeCreator to do this, but I'm also hoping to do multiple conditions on the attributer name, and so writing this into the SQL would be preferred.

Thankyou!

1 reply

erik_jan
Contributor
Forum|alt.badge.img+17
  • Contributor
  • October 25, 2017

I believe you want to replace

LEFT JOIN TABLEC e ON m.equip_no=e.equip_no and e.ATTRIBUTE_NAME='SERIALNUMBER'

with

LEFT OUTER JOIN TABLEC e ON m.equip_no=e.equip_no and e.ATTRIBUTE_NAME='SERIALNUMBER'


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings