How to create an hierarchy or break in SQL statement?

0

Hi all,

I've got a lot of dataframes which I'm trying to combine. One of the dataframes describe different processes with different codes, like this: Enter image description here

I make the JOIN On the 'ID", which is specifick for one location. But now I want to make a filter. Because the processes are superior to eachother. In the following order: 105 / 115 / 116 / 104. So I only want to see the code from proces 105. But if proces 105 doesn't exicst I only want the code of proces 116.

I tried making a case when clausle in the where: WHERE (CASE WHEN bls."Loc_type_code" = '105' THEN bls."Loc_type_code" WHEN bls."Loc_type_code" = '115'THEN bls."Loc_type_code" WHEN bls."Loc_type_code" = '116' THEN bls."Loc_type_code" WHEN bls."Loc_type_code" = '104'THEN bls."Loc_type_code" END)

But then I got an error: Right side of logical expression must evaluate to a boolean (actual: varchar). I hope you can help me :)

asked a year ago34 views
No Answers

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions