I was looking for the column "age" from table B, but when I used "b.age", it resulted in an error.
Error code
SELECT a.cuisine_type,
a.price,
할인률,
b,age,
a.price-(price*할인률) 'after_discount'
FROM
(
SELECT a.cuisine_type,
a.price,
b.age,
if(b.age>50,(b.age-50)*0.005,0) '할인률'
from food_orders a left join customers b on a.customer_id=b.customer_id
) a
order by 할인률 desc
The error occurred because the new query retrieves data from the subquery, so it couldn't find table B as all the data is sourced from subquery A.
'Issue Note' 카테고리의 다른 글
Difference between 'num for num in range' and 'for num in range' (Python) (0) | 2024.04.02 |
---|---|
Difference between list and [] (Python) (0) | 2024.04.02 |
DATE - [SQL} (0) | 2024.04.01 |
Exclusion of NULL values in b.customer_id column in SQL query [SQL] (0) | 2024.03.22 |
Red highlighted error [SQL] (0) | 2024.03.21 |