본문 바로가기

Study Note54

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.
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.
Replace Data in SQL and IF Statements String Manipulation1. REPLACE: Replace specified characters with others.2. SUBSTRING: Extract specific characters.3. CONCAT: Combine multiple strings for formatting.Conditional Statements1. IF: if(condition, value when condition is true, value when condition is false)2. CASE WHEN END: case when condition1 then value(expression)1 when condition2 then value(expression)2 else value(expressi.. 2024. 3. 20.
Calculating/Categorizing/Sorting Raw Data  Calculating ( + ) Not only addition but also multiplication and division are possible.select food_preparation_time, delivery_time, food_preparation_time + delivery_time as total_timefrom food_orders  result   Sum & Averageselect sum(food_preparation_time) total_food_preparation_time, avg(delivery_time) avg_delivery_timefrom food_orders    CountBy adding COUNT(1) or (*.. 2024. 3. 20.
Understanding database and SQL What is SQL and database SQL stands for Structured Query Language, a standardized programming language used to manage data in relational database management systems (RDBMS). A database is an organized collection of data stored electronically, designed to efficiently manage and retrieve data for applications and users.  I learned about handling tables, which gather data, and the way columns, whic.. 2024. 3. 19.