본문 바로가기

Study Note58

3. IF & loop IF is one of the most commonly used functions as a conditional statement. Here, IF, Else, and spacing are very important. Example money = 3000 if money > 3800: print ('Take taxi!') else : print ('Can not take taxi') print ('what to take?') money = 5000 if money > 3800: print ('Take taxi!') else : print ('Can not take taxi') print ('what to take?') If there are not space money = 5000 if money > 3.. 2024. 3. 25.
2. List & dictionary List The order of values is important. Using the 'list' function allows you to utilize the order of values and the listed words or numbers to access the values. a_list = [1,5,6,3,2] a_list.append(99) a_list.append(992) a_list.append(919) a_list.append(399) print(a_list) a_list = [1,5,6,3,2] result = a_list[:3] print(result) Dictionary It stores values as key-value pairs. a_dict = {'name' : 'bob'.. 2024. 3. 25.
1. Variable declaration and data types When learning Python, the most important thing is not to memorize all the code and concepts, but to improve the ability to become familiar with and utilize them in order to make the desired results. Here's an example regarding the most basic aspect of Python, which is inputting values: a = 3 print(a) b = a print(b) a = 5 print(a, b) # 5 3 # input value name = "jun " age = "18" # print the value.. 2024. 3. 25.
7. Pivot, Window function (Rank & sum), Date Pivot Pivot is commonly used in Excel, and I've learned that it can also be applied in SQL. Through the following example, I was able to create the result values in a pivot table format. select restaurant_name, max(if(hh='15', cnt_order, 0)) "15", max(if(hh='16', cnt_order, 0)) "16", max(if(hh='17', cnt_order, 0)) "17", max(if(hh='18', cnt_order, 0)) "18", max(if(hh='19', cnt_order, 0)) "19", ma.. 2024. 3. 22.
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.