Skip to main content
Question

Writing conditional values into SQL Creator

  • October 25, 2017
  • 1 reply
  • 10 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!

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

1 reply

erik_jan
Contributor
Forum|alt.badge.img+22
  • Contributor
  • 2179 replies
  • 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'