Skip to content
Advertisement

Null values affecting case logic

  • I am having a problem in the following query.
  • In the AR column there are some null values due to the left join of the wbr_global.raw_station_extended_attribute.
  • To fix this I added a case to default to 0 if it is null.
  • The issue this is causing is in my next case statement for assinging a station size.
  • All the null values are pulling in as “ds small” depsite their volume I am pulling in.
  • For example, the centroid stations in the picture orignially had null as the ar value but now have zero but has small pulling in when x-small should be assinged based on the sizing logic.

enter image description here

raw_station_extended_attribute table enter image description here

na_topology_lrp table enter image description here

Advertisement

Answer

I believe that the highlighted row has a station_ref of ‘ds small’ because of the ELSE statement at the end of the 2nd case statement. Further, you are using multiple ‘ar’ references here – ‘ar’ is used to reference the column both before and after processing the 1st CASE statement.

Try this:

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement