SQL (Structured Query Language) is a powerful programming language used for managing and manipulating relational databases. It allows users to create, retrieve, update, and delete data efficiently within a database system. SQL is widely used across industries for tasks ranging from data analysis to database management.
A relational database is a type of database that organizes data into structured tables (relations) with rows and columns.
Database
purpose of introduction with SQL
Understand databases and their structure
Extract Information from databases using SQL
Table show relation patrons, books and checkouts
Patrons Table
Column (field name)
Definition
card_num
card number
name
name
member_year
the year the patron became a library member.
total_fine
the total overdue
Relational Database – -> relation between tables of data insider the database
Database Benefits
Database have more storage than spreadsheet application.
Many users can write queries to gather insights from the data at the same time.
when a database is queried, the data stored insider the database not change.
Tables
Definition
databases are organized into tables, which hold related data about a particular subject.
tables are organized into rows and columns.
in the world of databases, rows are often referred to as records and columns as fields.
relation between patrons table and checkouts table connect with card_num column, book table and checkouts table connect with id column.
Create Table Name
lowercase
no space and – in table name (use underscores instead)
plurals
Record and Field
Records
Laying the table : records
A record is a row that holds data on an individual observation.
records pf patron table
Fields
Laying the table : fields
A field is a column that holds one columns of data for all records.
fields of patrons table
Table manner
Qualification
Singular name
No lowercase
No space
be different from other field name
be different from the table name
restrict of create name
Assigned seats
A unique identifier is used to identify records in a table.
Distinct and often number.
unique identifier
Create books table
A database has been set up for this course and the books table is available here.
Run the code to explore what data books holds!.
SELECT * FROM books;
SQL data types
When a table is created, a data type must be indicated for each field. The data type is chosen based on the type of data that the field will hold a text and number.
String data type: field name, Integer data type : field member_year, Floats data type : field total_fine
SQL Data type
Attribute
String
letters or punctuation
Integers
whole number
Floats
fractional number
String
String is a sequence of characters such as letters or punctuation.
VARCHAR is a flexible and popular string data type in SQL.
String field : field name
Integers
Integers is wholenumber
INT is popular integer data type in SQL.
Integer field : field member_year
Floats
Float store numbers that include a fractional part
NUMERIC is popular float data type in SQL
Float field : field total_fine
Schema
A schema shows a database’s design, such as what tables are included in the database and any relationships between its tables.
Schema show database’s design
Querying
Introducing queries
Benefits of SQL
use SQL to find which books James checked out from the library in 2022.
relation between card_num checkouts tables and patrons table.
use SQL queries to uncover trends in website traffic, customer reviews, and product sales.
Question
Which products had the highest sales last week?
Which products get the worst review scores from customers?
How did website traffic change when a feature was introduced?
Keyword
Keyword is word for operations. Common keywords : SELECT, FROM
The SELECT keyword indicates which fields should be selected
The FROM keyword indicates the table in which these fields are located
Keyword SELECT and FROM
SELECT name FROM patrons;
Selecting multiple fields
Can select field to that want show data example card_num and name
SELECT card_num, name FROM patrons;
It will show field that select first as picture below.
SELECT card_num, name vs SELECT name, card_name
Selecting all fields
if you want to show all data use asterisk(*) to select all four field name.
SELECT * FROM patrons;
SELECT * FROM patrons;
Writing queries
Aliasing (Rename Column)
Use aliasing to rename column.
Use SELECT name AS first_name to change field name from name to be first_name.
SELECT name AS first_name, year hired
FROM employees;
SELECT name AS first_name
Selecting Distinct Records
if you select year_hired it will show result duplicate year 2020 and 2021
we can add the DISTINCT keyword before the year_hired that make data show 4 year distinct.
SELECT DISTINCT year_hired
FROM employees;
SELECT DISTINCT year_hired FROM employees;
Distinct with multiple fields
add the DISTINCT keyword before the fields to select
the department id and year_hired fields still have repeat values individually, but none of the records are the same
SELECT DISTINCT dept_id, year_hired
FROM employees;
SELECT DISTINCT dept_id, year_hired FROM employees;
Views
A view is a virtual table that save SQL SELECT statement
When accessed, views automatically update in response to updates in the underlying data.
CREATE VIEW employee_hires_years AS
SELECT id, name, year_hired
FROM employees;
CREATE VIEW, then the name will create the new view.
Using views
we can query it just as we would a normal table by selecting FROM the view.
SELECT id, name
FROM employee_hire_years;
SELECT id, name FROM employee_hire_years;
-- create the view:
CREATE VIEW library_authors AS
SELECT DISTINCT author AS unique_author
FROM books;
-- Select all columns from library_authors
SELECT * FROM library_authors
sample of CREATE VIEW use case.
Viewing your query
You have worked hard to create the below SQL query:
SELECT DISTINCT author AS unique_author
FROM books;
SQL flavors
Both free and paid
All used with relational database
Vast majority of keywords are the same
All must follow universal standards
Two popular SQL flavors
PostgreSQL
SQL Server
Free and open-source relational database system.
Has free and paid version
Created at the university of California, Berkeley
Create by Microsoft
“PostgreSQL” refers to both the PostgreSQL database system and its associted SQL flavor
T-SQL is Microsoft SQL flavor, used with SQL Server databases
Comparing PostgreSQL and SQL Server
--PostgreSQL:
SELECT id, name
FROM employees
LIMIT 2;
--SQL Server:
SELECT TOP(2) id, name
FROM employees;
PostgreSQL vs SQL server
SQL Server using the TOP keyword instead of LIMIT. Notice that this keyword is the only difference between the two queries!
Summary
“I hope the foundational knowledge for advancing projects in the following five areas will be helpful for everyone:
Data analyst is an essential tool that enables organizations to gain deeper insights into their data. Utilizing Microsoft Excel for efficient data processing facilitates accurate and prompt decision-making while identifying trends and uncovering new business opportunities.
Excel work with a prepared spreadsheet that contains sale
The 5 steps for analyzing the sales_data_analysis.xlsx file in Microsoft Excel 365 are as follows
Upload a document using the free online version of Microsoft Office 365
One drive to upload excel file
Click add new → File upload → then upload → sales_data_analysis_23.10.2024
Go to Insert → Table to create a table that uses the header in the first column to filter data. → Click OK.
To Createa table to filter data, see the picture below.
Create Table in microsoft excel 365
Then filter the data shown in the picture below.
can filter data by columns such as Num, Date, Month, Sales Rep, Region, Customer ID, etc.
Set it up so that when you scroll down to view data in the rows below, the first column remains visible. This makes it much easier to reference the headings.
Perform data analysis using sorting and filter tools.
Which column should be prioritized for sorting data to make it more effective?
representative header and then select sort A to Z to sort it in alphabetical order
Sort the Sales Rep column from A to Z.
after click it has been rearrange by alphabetical Sales Rep
then to make it back to select sort in column date again
can sort the Region by North.
Filter by North Region.
To remove the filter, click the ‘Select All‘ checkbox to display sales from the North, South, and West regions, and then click.
Then filter the Sales Rep column by the name David Garcia.
Calculate in the bottom right corner.
What you can see from data?
Average of $7,893
Count of 9
Sum of $71,040
you can see aggregate value in the bottom right corner.
This is how to use the sorting and filtering tools to rearrange your data.
Perform data mining using the IF Function
The idea behind data mining is to take the data you already have and create new or additional data from it.
The IF function is frequently used.
Samples show that when an order includes 20 chairs or more, the client receives a 5% wholesale discount.
Discount Column 3 Method
1. Create a discount column to the right to reflect this.
2. In the column, use ‘Y‘ for orders with a quantity ≥ 20.
3. In the column, use ‘N‘ for orders with a quantity ≤ 20.
Code for column Discount
=IF(J5>=20,"Y","N")
Create a discount column based on the quantity in the number column.
Final Price column
Code for column Final Price
=IF(J5>20,0.95*L5,L5)
Create a Final Price column based on discount and number column.
column of Discount with Y is number ≥ 20 price is discount 5% final is 95% from total column
column of Discount with N is number ≤ 20 price is same as the total
Create references between tables and search for information with VLOOKUP
Goal is to insert the company name using the client ID.
Create column Company Name between Customer ID and Color
Create column Company Name Representative between Company name and model
Data analysts help organizations gain valuable insights from data. Using Microsoft Excel enhances decision-making by processing data efficiently and identifying trends and opportunities.
สามารถดึงข้อมูลจาก Social Media Platforms ด้วยตัวเอง เช่น Facebook, Instagram, Twitter โดยใช้ Supermetrics + Google Sheets
Google Sheets & Looker Studio
โดย 2 เครื่องมือที่นิยมใช้ในงาน Social Listening คือ Excel/ Google Sheets และ BI Tools เช่น Looker Studio หรือ Power BI เพื่อทำรายงาน dashboard ติดตามผลง่ายๆ
ใช้สำหรับ Social Listening ใช้ Google Sheets + Looker Studio เป็นหลัก
Case Study : Oppo Find N2 Flip Launch
ทีมการตลาดของ Oppo Global ได้หา insights ว่าลูกค้าที่ใช้โทรศัพท์จอพับมีปัญหาอะไรบ้าง (จากการทำ research และ social listening) พบว่าสามปัญหาที่ลูกค้าบ่นเยอะที่สุดคือ
ระหว่าง Extract กับ Analyze ใช้ Negative key word ในการดึงข้อมูลที่ไม่สำคัญทิ้งไป
Sub keyword ใช้ในการวิเคราะห์ เช่น กล้อง ราคา promotion
Zocial Eye Dashboard รูปภาพจาก Social Listening — Data Analyst Edition by DataRockie
Extract Data for Zocial Eye
Extract Data From Platform
การดึงข้อมูลจาก Platform ต่างๆ
Facebook Data
Instagram Data
Application Program Interface
Facebook Data
จะเริ่มดึงข้อมูลจาก Social Media Platform โดยใช้ Supermetrics ในการดึงข้อมูลจาก facebook public page
สามารถใช้ application นี้ฟรี 14 วัน
ตัวอย่างนี้เป็นการลองดึงข้อมูลจาก Facebook Public Post แบบง่ายๆด้วย Supermetrics แค่เลือก data source -> page -> period -> dimensions/ metrics ที่ต้องการ
Instagram Data
Extract ข้อมูลผ่าน IG Data
โดยการดึงข้อมูลจาก Instagram ผ่าน hashtag
Application Program Interface
รูปภาพ API Process จาก Social Listening — Data Analyst Edition by DataRockie
API ย่อมาจาก “Application Program Interface” (ส่วนต่อประสานโปรแกรมประยุกต์) ในบริบทของ API คำว่า “Application” หมายถึงทุกซอฟต์แวร์ที่มีฟังก์ชันชัดเจน ส่วน “Interface” อาจถือเป็นสัญญาบริการระหว่างสองแอปพลิเคชัน ซึ่งสัญญานี้จะกำหนดวิธีที่ทั้งสองสื่อสารกันโดยใช้คำขอและการตอบกลับ
รูปภาพ keyword and sub keyword จาก Social Listening — Data Analyst Edition by DataRockie
Check Period
หาช่วงเวลาให้ตรงกับที่เราสนใจก่อน แล้วจะได้เปรียบเทียบข้อมูลทั้ง 3 platform facebook, new and other
check period หาช่วงเวลาให้ตรงกับที่เราสนใจก่อน แล้วจะได้เปรียบเทียบข้อมูลทั้ง 3 platform facebook, new and other รูปภาพจาก Social Listening — Data Analyst Edition by DataRockie
สามารถดูหน้าโพสต์นั้นผ่าน All channels skoodio Page ได้เลย
สามารถเปลี่ยน sub keyword หรือ message ที่จะหาได้ตลอดเลย
สามารถดู sentiment ได้ตรง top message engagement ได้เลย
รูปภาพจาก Social Listening — Data Analyst Edition by DataRockie
Do sentiment analysis for this “message” using options [“neutral”, “positive”, “negative”].
Aggregate Data
ก่อนที่เราจะเข้าสู่ Phase 3 [Present] ของโปรเจ็ค Social Listening เราจะทำการ Aggregate Data ให้อยู่ในรูปแบบ Table ที่เข้าใจง่ายๆก่อน
เครื่องมือที่เราใช้ทำ Aggregate Data ที่ง่ายที่สุดคือ Pivot Table ใน Excel/ Google Sheets หรือจะใช้ BI Tools ที่กำลังเป็นที่นิยมตอนนี้ เช่น Looker และ Power BI ก็ได้
5. Word Cloud ใช้แสดงผลข้อความ phrase หรือ #hashtag ที่มีการ mentions เยอะๆในข้อมูล font size ยิ่งใหญ่ แปลว่ามีการพูดถึงคำนั้นเยอะ
Word Cloud สำหรับคำที่มีการพูดถึงเยอะ
Zocial Eye Dashboard มี common charts ทั้งหมดนี้ให้เราใช้งานได้เลย แต่ถ้าอยากจะ export data ออกมาทำเองแบบ manual ก็ได้เช่นกัน (หรือเอา raw data ไปขึ้น BI tools)
เราสามารถโหลดข้อมูลที่ได้จาก Social Listening Tools เข้า Business Intelligence (BI) Software เช่น Looker Studio, Power BI หรือ Tableau เพื่อทำ Report และ Dashboard เสนอผลวิเคราะห์
สำหรับ Program Google Looker Studio มีขั้นตอนดังนี้
Export file csv to looker studio
+ Blank Report page in looker studio
click to upload file
add to report
แล้วสามารถใส่ chart ตามใจชอบ
Sample Looker Studio
Slide Making
ทีม Data Analyst ใช้ Slide Presentation ในการนำเสนอ Insights ที่น่าสนใจ
Software ที่เราใช้ทำ Slide Presentation เช่น
PowerPoint (Windows)
Keynote (Mac OS)
Google Slides (Web-Based)
Canva (Web-Based)
Tip – หลายคนอาจจะไม่รู้ แต่ Slide Making คืออีกหนึ่งทักษะสำคัญของการเป็น Data Analyst ที่ดีเลย หรือที่เราเรียกกันว่า Communication Skill (ใน Job Description/ Requirement)
Slide Making
Limitations of Social Listening Data
ข้อจำกัดของข้อมูล Social Listening ที่เราเก็บเข้ามาในระบบ
เราไม่สามารถแยกระหว่าง Organic vs. Paid ได้ นอกจากเราจะเป็นเจ้าของ Page/ Channel นั้นๆถึงจะรู้ว่าโพสต์ไหนบ้างใช้เงินอัดโฆษณา
Boost post
เรื่องการ Update ระบบ Social Listening จะมีรอบในการวิ่งกลับไปเก็บข้อมูลล่าสุด เช่น Post วันที่ 1 ก.ย. 2023 จะมีการวิ่งกลับไปเก็บอีกสองครั้งวันที่ 8 และ 15 ก.ย. 2023 หลังจากนั้น ระบบจะหยุดเก็บข้อมูลแล้ว ทำให้ตัวเลขบน Social Media กับใน Report อาจจะไม่ตรงกันเป๊ะ 100%
Social Media Inaccuracy
Social media platforms บางตัวยังไม่เปิดให้ใช้งาน Public API เช่น TikTok (อัพเดท ต.ค. 2023) หรือมี API ให้ใช้ แต่ไม่ส่งค่าบางอย่างกลับมาเช่น Facebook API ยังไม่แชร์ค่า Video Views บน Page กลับมาให้เราวิเคราะห์ต่อ ต้องไปดึงแบบ manual เอง
3. Talk about what you’re writing – เล่าให้คนอื่นฟังว่าเรากำลังเขียนอะไรอยู่ เพราะ “Knowledge is conversational” เพื่อนๆรอบตัวเราอาจมี Insights ที่ช่วยให้เราเขียนเรื่องนั้นดีขึ้นก็ได้
5. Do writing exercises – ฝึกเขียนด้วยเทคนิค ”Free Writing” คิดค้นโดย Peter Elbow ในปี 1973 เป็นการเขียนที่ปลดล็อคความคิด ไม่มีข้อจำกัดใดๆ เหมือนการ ”Warm Up” ก่อนเขียนงานหลักของเรา
6. Organize your material – รวบรวมและจัดเรียงข้อมูลเพื่อสร้าง Story ที่เราอยากเล่า Gary แนะนำ “ให้เก็บมากกว่าที่เราจำเป็นต้องใช้” ยิ่งมี Input มากเท่าไหร่ เรายิ่งเขียนได้ง่ายขึ้นเท่านั้น
7. Make a list – เขียนลิสต์สิ่งสำคัญที่เราอยากจะ Cover ในบทความ สร้าง Outline ง่ายๆ เช่น สิ่งที่เราอยากให้ผู้อ่านได้รับ Key Message, Questions และ Takeaways
8. Picture a reader – นึกถึงหน้าผู้อ่านอยู่ตลอดเวลา นึกภาพเค้านั่งอ่านอยู่ข้างเรา อย่าใช้คำศัพท์ที่ทำให้เค้าหันมาถามเราว่า “ประโยคเมื่อกี้แปลว่าอะไร”
9. Ask yourself why – ถ้าเราตอบไม่ได้ว่าเราจะเขียนงานนั้นไปเพื่ออะไร อย่าเสียเวลาเขียนเลย ทุกงานเขียนต้องมีหนึ่ง “Job to be done” เสมอ เช่น ทำให้คนหัวเราะ ซื้อของ ร้องไห้ หรือได้ความรู้ ฯลฯ
On Writing Well ของ อ. William Zinsser คือที่สุด เรียกว่าระดับตำนานของแทร่ เขียนยังไง สไตล์ไหน ให้เข้าถึงใจผู้อ่าน เป็นเล่มที่คิดว่าต้องอ่านๆซ้ำ จะดีมากถ้าได้อ่านทุกปี
วิธีการเริ่มเขียนเบื้องต้นก็สามารถเริ่มได้จากการฝึกเขียนส่วนตัว แบบ Short form , Long form เปิดเว็บไซต์
My Personal Workflow
ใช้ database table เป็นอุปกรณ์พิเศษที่ช่วยในการจัดการว่ามี list อะไรสำคัญบ้าง เช่น Episode, Date, Tag, Content, URL, Status
การมีอุปกรณ์ที่ดีในการช่วยเขียน สามารถช่วยให้เราเขียนงานได้ดีขึ้นหลายเท่า เช่น Notion เป็น software หลักในการสร้าง digital second brain ประยุกต์ใช้ CODE method รัวๆ
Type
Definition
Episode
ตอนที่, บทที่
Date
วันที่
Tag
ประเภทของบทความ
Content
ชื่อบทความหรือหนังสือ
URL
link หนังสือหรือเว็บไซต์
Statue
สถานะว่าทำเสร็จหรือยัง
A Very Normal Daily Routine
ตารางชีวิตแอดทอยจะประมาณนี้ๆ มีคลาดเคลื่อนบ้างนิดหน่อย Cheat Day 555+
บทความนี้อยากช่วยแนะนำแนวทางในการเรียนรู้และปรับตัวต่อโลกยุคใหม่ ให้ทุกคนสามารถเข้าใจความสำคัญของ business และ AI ผ่านคุณ Andrew NG หนึ่งในผู้นำด้าน AI ระดับโลก เป็นผู้ทรงอิทธิพลด้าน AI ติดอันดับ Time100 ในปี 2023 😍😍😍
การจะทำให้เทคโนโลยีหรือเครื่องมือ AI ประสบความสำเร็จได้นั้น ต้องมีอีกส่วนที่ประสบความสำเร็จมากกว่า คือ การประยุกต์ใช้ที่สร้างเพิ่มขึ้นมา
สำหรับธุรกิจจำนวนมาก เป้าหมายของคุณ ไม่ควรจะแข่งขันกับคนสร้างเครื่องมือ AI แต่ควรเน้นไปกับการสร้างการใช้งานให้กับเครื่องมือ AI ต่างหากคือจุดที่สร้างมูลค่าได้มากที่สุด
ควรเน้นการสร้างการใช้งานให้กับเครื่องมือ AI ต่างหากคือจุดที่สร้างมูลค่าได้มากที่สุด
การสร้างการใช้งาน AI สำหรับองค์กร
1. วันนี้คนทำงานภายในองค์กรทุกคนสามารถเพิ่มประสิทธิภาพการทำงานได้อย่างมีนัยสำคัญด้วยการเรียนรู้การใช้ Generative AI
ควรจัดฝึกอบรมความรู้ให้พนักงานรู้เรื่อง Generative AI
2. เรื่องผลกระทบต่อแรงงาน AI จะมาช่วยปรับการทำงานบางอบ่างให้เป็นอัตโนมัติแทนที่จะมาแทนที่ตำแหน่งงานทั้งหมดนั้นมีประโยชน์กว่า
AI มาแทน Task ไม่ใช่ Job
3. AI อาจเปลี่ยนแปลงครั้งยิ่งใหญ่ได้ในบางอุตสาหกรรม
ถ้า AI สามารถใช้แรงงานแทนคนในอุตสาหกรรมได้ เราต้องคิดว่าจะต้องปรับตัวอย่างไรให้อยู่รอดในอุตสาหกรรมนั้นต่อไปได้
ต้องประเมินก่อนว่า AI สามารถทำอะไรได้และไม่ได้บ้าง
การประเมินความยากในการสร้างรถยนต์ขับเคลื่อนอัตโนมัติต่ำไป เนื่องจากการประเมินทางเทคนิคเรื่อง AI ว่าสามารถประเมินได้ถูกต้องมากกว่าผิดพลาดนั้น ไม่ได้ถูกต้องเสมอไป
เช่นการประเมินด้านโลจิสติกส์หรือด้านสุขภาพต้องมีด้านเทคนิคดับ AI จึงบอกว่าไอเดียสามารถทำได้หรือไม่ได้อย่างแน่ชัด