본문 바로가기

Category87

NULL value In SQL, Null  means nothing at all. This is not 0, it's NULL. When a field is 0, it is included in calculations, but when it's NULL, it's completely excluded from calculations. If you want to exclude Null in the result, you can use Where and is not null query. select a.order_id, a.customer_id, a.restaurant_name, a.price, b.name, b.age, b.genderfrom food_orders.. 2024. 3. 22.
Exclusion of NULL values in b.customer_id column in SQL query [SQL] I had a question about the above SQL code. Looking at the code, the query 'where b.customer_id is not null' is searching for non-null values in the customer_id column. However, there are no null values in the b.customer_id column, and null values in b.name and b.age are excluded. I was curious about the reason for this. select a.order_id, a.customer_id, a.restaurant_name, a.price, b.name, b.age,.. 2024. 3. 22.
Table name from Subquery [SQL] 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 th.. 2024. 3. 21.
Red highlighted error [SQL] I received an error message, but the result is fine. I can't find any issues, but the SQL system highlighted the word. SELECT a.cuisine_type, a.price, discount, age, a.price-(price*discount) 'after_discount' FROM ( SELECT a.cuisine_type, a.price, b.age, if(b.age>50,(b.age-50)*0.005,0) 'discount' from food_orders a left join customers b on a.customer_id=b.customer_id ) a order by discount desc 2024. 3. 21.
Left Join & Inner Join JOIN function is used to combine two or more tables to create a single result set. JOIN typically defines the relationship between two tables based on specific conditions and combines rows accordingly. Major JOIN types include INNER JOIN, LEFT JOIN, RIGHT JOIN, and FULL JOIN. However, I am going to write only about LEFT JOIN, INNER LEFT JOIN in this posting 1. LEFT JOIN includes all rows from th.. 2024. 3. 21.
Subquery 1) When a Subquery is needed     When multiple operations need to be performed        → Determine the time value to charge the fees        → Add extra fee based on order amounts        → Calculate the final estimated delivery fee based on the applied weights    When the results of operations are needed in conditional statements        → When wanting to divide food expenses into high/medium/low .. 2024. 3. 21.