Bài đăng

Đang hiển thị bài đăng từ Tháng 1, 2025

07 - Having vs Where in MySQL

Hình ảnh
  https: // youtu.be / dCNjUOc1cBY?si = 98wPr8SDYuRBXsGn TOTAL: 3 . 45 mins -- Having vs Where -- Both were created to filter rows of data, but they filter 2 separate things -- Where is going to filters rows based off columns of data -- Having is going to filter rows based off aggregated columns when grouped SELECT gender, AVG (age) FROM employee_demographics GROUP BY gender ; -- let's try to filter on the avg age using where -- đã nhóm = GROUP BY rồi là không dùng WHERE để lọc => đó là lí do HAVING ra đời -- HAVING -> lọc trên kết quả đã nhóm SELECT gender, AVG (age) FROM employee_demographics WHERE AVG (age) > 40 GROUP BY gender ; -- this doesn't work because of order of operations. On the backend Where comes before the group by. So you can't filter on data that hasn't been grouped yet -- this is why Having was created SELECT gender, AVG (age) FROM employee_demographics GROUP BY gender HAVING AVG (age) > 40 ; SELECT gender, AVG (age) as AVG...

06 - Group By + Order By in MySQL

Hình ảnh
https: // youtu.be / zgYqUP_PhQo?si = UxhPuDkIcGB8n5v5 TOTAL: 10 . 45 mins -- Group By -- When you use the GROUP BY clause in a MySQL query, it groups together rows that have the same values in the specified column or columns. -- GROUP BY is going to allow us to group rows that have the same data and run aggregate functions on them SELECT * FROM employee_demographics; -- when you use group by  you have to have the same columns you're grouping on in the group by statement SELECT gender FROM employee_demographics GROUP BY gender ; SELECT first_name FROM employee_demographics GROUP BY gender ; SELECT occupation FROM employee_salary GROUP BY occupation ; -- notice there is only one office manager row -- when we group by 2 columns we now have a row for both occupation and salary because salary is different SELECT occupation, salary FROM employee_salary GROUP BY occupation, salary ; 02 : 22 -- now the most useful reason we use group by is so we can perform out aggregate fu...

05 - Where Clause in MySQL

Hình ảnh
  https: // youtu.be / MARn_mssG4A?si = BWZz_BJREcBsmbrv Total: 12 . 26 mins -- WHERE Clause: -- ------------- -- The WHERE clause is used to filter records (rows of data) -- It's going to extract only those records that fulfill a specified condition. --  So basically if we say "Where name is = 'Alex' - only rows were the name = 'Alex' will return --  So this is only effecting the rows, not the columns -- Let's take a look at how this looks SELECT * FROM employee_salary WHERE salary > 50000 ; SELECT * FROM employee_salary WHERE salary >= 50000 ; SELECT * FROM employee_demographics WHERE gender = 'Female' ; -- We can also return rows that do have not "Scranton" SELECT * FROM employee_demographics WHERE gender != 'Female' ; -- We can use WHERE clause with date value also SELECT * FROM employee_demographics WHERE birth_date > '1985-01-01' ; -- Here '1990-01-01' is the default data formate ...

04 - Select Statement in MySQL

Hình ảnh
https://youtu.be/HYD8KjPB9F8?si=A8GAsx6CAOo0oHRY TOTAL: 11 MINS 02 : 51 Thử chọn schema khác và chạy dòng lệnh cũ -> báo lỗi do sai db active => nếu thao tác trên server có nhiều db cùng lúc phải gõ tendb.table 09 : 02 SELECT distinct gender FROM parks_and_recreation.employee_demographics; => k cho trùng cột gender -- SELECT STATEMENT -- the SELECT statement is used to work with columns and specify what columns you want to work see in your output. There are a few other things as well that -- we will discuss throughout this video -- We can also select a specefic number of column based on our requirement. -- Now remember we can just select everything by saying: SELECT * FROM parks_and_recreation.employee_demographics; -- Let's try selecting a specific column SELECT first_name FROM employee_demographics; -- As you can see from the output, we only have the one column here now and don't see the others -- Now let's add some more columns, we just need to separ...

Giới thiệu trại hè Data Analysis - Nghề Analysis - Cài đặt MySQL 8x LTS

Hình ảnh
  01 - FREE Data Analyst Bootcamp!! https://youtu.be/rGx1QNdYzvs?si=GsBGmnl7kQQGPwm2 02 - How to Become a Data Analyst in 2023 (Completely FREE!) https://youtu.be/CUBfrdDwznQ?si=VzH9pCA7RKxtjQr3 03 - Installing MySQL and Creating Databases https://youtu.be/wgRwITQHszU?si=L4vzUHBKzZmfJr5M 01:15 link download MySQL: https://dev.mysql.com/downloads/installer/ LTS - Long Time Support Vào Microsoft Store cài cũng tương tự (có thể thiếu workbench) + chọn No, thanks... + Excute chứ không Next (cẩn thận cài thiếu) + chọn cài FULL + Cài Visual C++ (auto) https://www.techspot.com/downloads/6776-visual-c-redistributable-package.html + Trong tab Navigator - Chọn Schemas + Chạy đoạn code này để tạo data (03 tables) 09:45 Right click lên table - Select Row limit to 1000 (thử đổi lại 10 rồi chạy lại câu query) 10:45 Thử chạy thêm table salary ở dưới chung với dòng cũ -> test nút chạy từng dòng (Ctrl + ENTER) DROP DATABASE IF EXISTS `Parks_and_Recreation` ; CREATE DATABASE ` Parks_and_...