Hi @Benjamin Chew ,
Welcome to Microsoft Q&A!
I would like to check if it is possible to have the column rename with the as keyword in the where statement, for example the level_1_data column?
Could you please provide more details about above?
If you would like to add the alias or rename the column in below part, it is impossible.
where response_row_id=r.level_3_row_id
If you would like to add alias to the column like below, it is possible.
select level_data as level_1_data from ResponseRow where response_row_id=r.level_3_row_id
If you would like to add the where condition in the final part like below, it would show some errors.
FROM ResponseRow r
where level_1_data=1
You could update above part like below:
FROM ResponseRow r
where Coalesce(NullIf(r.level_data,''),(select level_data from ResponseRow where response_row_id=r.level_3_row_id))=1
If you still have some concern, we recommend that you post CREATE TABLE statements for your tables together with INSERT statements with sample data, and your updated query desired. We also need to see the expected result of the sample.
Best regards,
Melissa
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.