Automatically translated.View original post

Query Function Guide in SQL-like Google Sheets

2025/1/25 Edited to

... Read moreถ้าเพิ่งเริ่มใช้ =QUERY ใน Google Sheets แล้วรู้สึกเหมือน “เขียน SQL ในชีต” บทนี้คือสรุปสิ่งที่เรามักต้องใช้จริงเวลาเป็น data analyst: กรองข้อมูล, เรียงลำดับ, และสรุปผลแบบรายกลุ่ม (เหมาะกับข้อมูลเล็ก-กลางในชีต) 1) โครงสร้างสูตรที่ควรรู้ รูปแบบพื้นฐานจะประมาณนี้: =QUERY(A1:F, "select A,B where C > 90 order by C desc", 1) - A1:F คือช่วงข้อมูล - ข้อความในเครื่องหมายคำพูดคือคำสั่งคล้าย SQL - เลขตัวท้าย (1) คือจำนวนแถวหัวตาราง (header) ทิป: ถ้าช่วงข้อมูลมีหัวตารางจริง ๆ ใส่ 1 จะช่วยให้แปลคอลัมน์ถูกต้องและผลลัพธ์ไม่เพี้ยน 2) เข้าใจการอ้างคอลัมน์ใน QUERY ใน Query จะอ้างคอลัมน์เป็น Col1, Col2… ตามลำดับในช่วงข้อมูลที่เลือก เช่นเลือกช่วง A:D - A = Col1, B = Col2, C = Col3, D = Col4 เวลาแก้สูตร เราชอบเผลอเพิ่มคอลัมน์แทรกกลางชีต แล้ว Col จะเลื่อนได้ แนะนำให้กำหนดช่วงให้ชัด (เช่น A1:H) และเช็ก Col ใหม่ทุกครั้ง 3) เรียงลำดับมากไปน้อย (ORDER BY) กรณีฮิตมาก: google sheet เรียง ลํา ดับ มากไปน้อย =QUERY(A1:D, "select Col1,Col4 order by Col4 desc", 1) - desc = มากไปน้อย - asc = น้อยไปมาก ถ้าตัวเลขถูกมองเป็นข้อความ (เรียง 100 ก่อน 9) ให้ตรวจว่าคอลัมน์เป็นชนิดตัวเลขจริง และไม่มีคอมม่า/สัญลักษณ์ติดอยู่ 4) กรองเงื่อนไขหลายอย่าง (WHERE + AND) ตัวอย่างแนวพนักงาน “เงินเดือนเกิน 50,000 และอยู่กรุงเทพฯ”: =QUERY(A1:E, "select Col1,Col3,Col5 where Col4 > 50000 and Col2 = 'กรุงเทพฯ'", 1) ทิป: ข้อความต้องใส่ '...' เสมอ เช่น 'กรุงเทพฯ' 5) สรุปผลแบบรายกลุ่ม (GROUP BY + SUM/AVG) ถ้าอยากสรุปเงินเดือนเฉลี่ยและจำนวนคนต่อแผนก: =QUERY(A1:D, "select Col2, avg(Col4), count(Col1) group by Col2", 1) แล้วจัดหัวคอลัมน์ให้อ่านง่ายด้วย LABEL: =QUERY(A1:D, "select Col2, avg(Col4), count(Col1) group by Col2 label avg(Col4) 'เงินเดือนเฉลี่ย', count(Col1) 'จำนวนพนักงาน'", 1) 6) กรองวันที่ (PARSE_DATE) ถ้าวันที่ในชีตเป็นข้อความ เช่น 2025-01-15 และอยากกรองช่วงวัน: =QUERY(A1:D, "select Col1,Col3 where Col2 >= date '2025-01-01'", 1) หรือถ้าเป็นข้อความรูปแบบอื่น ค่อยแปลงด้วย PARSE_DATE ในคอลัมน์ช่วย แล้วค่อย Query จะนิ่งกว่า 7) เช็กลิสต์แก้ปัญหาที่เจอบ่อย - #N/A หรือ parse error: มักมาจากเครื่องหมายคำพูด, วงเล็บ, หรือชื่อคอลัมน์ Col ผิด - ตัวคั่น (comma/semicolon): บางโลเคลใช้ ; แทน , ในสูตร - ช่วงข้อมูลไม่ครอบคลุม: เพิ่มแถวแล้วผลไม่อัปเดต ให้ใช้ช่วงแบบ A1:F แทน A1:F20 ลองเริ่มจาก “select + where + order by” ให้คล่องก่อน แล้วค่อยต่อยอดไป group by/sum/avg จะรู้สึกว่า QUERY Google Sheets ช่วยย่นเวลาแทบทุกงานสรุปรายงานเลย

Related posts

A flat lay image featuring a pink notebook, gold heart-shaped dish with paperclips, and a gold pen, alongside a keyboard and pink flowers. The text overlay reads "5 FREE ONLINE CERTIFICATIONS to Boost YOUR RESUME."
The image displays the logo for "Learning How to Learn" with a brain and sun icon. Text describes this Coursera course from UC San Diego, focusing on improving learning techniques, memory, and study strategies.
The image shows the "Learn SQL" logo. Text describes Codecademy's free SQL course, emphasizing its importance for data analysis, database management, querying, creating tables, and manipulating data.
5 Free Online Certifications to Boost Your Resume
Hi, lemons! In today's competitive job market, having a standout resume is crucial. Employers seek candidates with not only relevant experience but also a commitment to continuous learning. Fortunately, the digital age offers a wealth of free online certifications that can enhance your skill se
Lifestyle Babe

Lifestyle Babe

743 likes

📋 Calendar + Task Tracker + Time Log
The only planner you need 📋 Calendar + Task Tracker + Time Log — all in one Excel & Google Sheets template #planner #excel #googlesheets #calendar #spreadsheet
Loving.Templates

Loving.Templates

111 likes

Canva Brand Board Tutorial For Beginners
Canva Tutorial For Digital Marketers. How To Make A Brand Board For Your Business Using Canva! #canvatips #canvatutorial #canvaforsmallbusinesses #canvahacks
Inuri

Inuri

132 likes

The first image is a laptop screen displaying 'LEARN SQL FOR BEGINNERS PART 3' as part of a guide titled 'How to become a Data Analyst'.
This image illustrates an SQL query using `WHERE major = 'Biology'` to select specific rows from a `students_table`, showing the filtered result with only Biology majors.
This image demonstrates an SQL query using `WHERE major = 'Biology' OR major = 'History'` to filter a `students_table` for multiple majors, showing the combined result.
Swipe if you’re a beginner & want to learn SQL!
In this post, we'll learn how to select specific rows from your table using a WHERE statement. As a recap, we've already learned about a few other statements, and we know that the statements have to come in a specific order. Only the SELECT and FROM statements are required. Here's
Delara 💖👩🏻‍💻

Delara 💖👩🏻‍💻

372 likes

A list titled "12 Smart Ways to Use Google Gemini" on a paper background. It outlines functionalities like converting videos/audio to text, creating images, deep research, infographics, Gems, podcasts, Google app integration, web app building, guided learning, video generation, and quiz creation.
12 Smart Ways to Use Google Gemini
Dr Cynthia Chirwa

Dr Cynthia Chirwa

165 likes

Data Analysts Career Guide: SQL Query Optimization
Hello everyone! I wanted to share tips for optimizing SQL query performance. Using indexes effectively on key columns and selecting specific columns can speed up data retrieval. Additionally, minimizing nested queries and optimizing join operations enhances efficiency. Moreover, limiting unnecessar
Yun Jung

Yun Jung

15 likes

✨👩🏾‍💻🎒Websites EVERY STUDENT Should Have SAVED 💻👩🏾‍🎓✨
✨ Whether you’re in high school, college, or grad school, the right websites can make your study life 10x EASIER. These tools help with research, organization, studying, and even saving money. Bookmark them NOW! 🗂️ ✨ Must-Visit Student Sites: 1️⃣. Quizlet — Digital flashcards for memorizing ter
Margarita

Margarita

729 likes

A person on a balcony overlooking a scenic coastal town with white buildings and blue domes, with text overlay "DATA SCIENTIST What to study" and "AVERAGE SALARY - $140000".
Text overlay titled "1. Programming and Data Manipulation" listing Python, R, SQL, and Big Data Tools, set against a background of a modern balcony overlooking a coastal town.
Text overlay titled "2. Statistics and Mathematics" listing Linear Algebra, Probability and Statistics, and Calculus, set against a background of a coastal town with white buildings and the sea.
What to study to become a data scientist 🧑‍💻
1. Programming and Data Manipulation - Python: Learn libraries like Pandas, NumPy, and Scikit-learn for data manipulation and modeling. - R: Explore statistical analysis and visualization packages like ggplot2 and caret. - SQL: Master querying, managing, and manipulating structured data in relat
vedha | career tips (tech) 👩‍

vedha | career tips (tech) 👩‍

193 likes

Canva Hack For Planning Your Instagram Grid 😎
Canva Tutorial - How To Plan Your Instagram Grid Using Canva! #canvahacks #canvatips #canvatutorial #canvaforsmallbusinesses #canvaforbeginners
Inuri

Inuri

12 likes

Useful advanced SQL Queries for data analysts
Hello everyone! I wanted to highlight powerful SQL features that are helpful for data analysts! Common Table Expressions (CTEs) act as named temporary result sets within queries, simplifying complex logic with recursive operations or data aggregation. Window Functions enhance analytical capabilitie
Yun Jung

Yun Jung

33 likes

A woman with curly hair and glasses, holding a microphone, with text overlays 'SQL Windows Function Explained' and 'Mad Key'.
A bookshelf background with 'SQL Windows Function Explained' and a quote defining a window function as viewing a 'slice' of data while seeing the bigger picture.
A SQL code example using a window function (RANK() OVER) to rank sales, showing output with individual sales records and their ranks, maintaining detail.
SQL: Windows Function Explained
One thing I've discovered is that when working with data, Normal SQL (GROUP BY) helps summarize data but sacrifices row-level detail in the process. On the other hand, Window Functions allow you to perform calculations across rows while maintaining each row’s detail. This key difference m
NeLo

NeLo

57 likes

The image features a blurred background of a laptop, headphones, and a book, with text overlay stating, "If you're a student then you need to know HOW TO USE GOOGLE." It introduces a guide for students on effective Google search techniques.
This image, set against a blurred background of a workspace, details Google search tips including using quotation marks for exact phrases, dashes to exclude words, and tilde for synonyms, with examples for each.
Against a blurred background, this image presents advanced Google search operators: 'site:query' for specific websites, 'link:query' for linked sites, 'Two Periods' for numerical ranges, and 'related:query' for finding similar sites.
Students - How To Use Google!!
💻If you're a student then you need to know how to properly use Google!! 👩🏻‍💻Believe it or not, there are so many ways to use Google and so many ways that you can search for something! With these tips, you will be able to find what you are searching for quicker and way more efficiently! Q
CompSkyy

CompSkyy

307 likes

Tech Career Guide: SQL Best practices
Hello everyone! I wanted to share essential SQL best practices for effective database management. Design your database with normalization principles for streamlined data organization and integrity. Use indexes strategically on key columns to optimize query performance. Write efficient SQL queries b
Yun Jung

Yun Jung

221 likes

A handwritten list titled 'VERY IMPORTANT WORDS FULLFORM' from @ILMI_Dunya, detailing 15 essential tech and finance acronyms. It includes full forms for terms like OTP, PIN, QR code, SMS, MMS, WiFi, GIF, GPS, KYC, PDF, PNG, JPEG, URL, WWW, and PAN.
Essential Tech Acronyms Unveiled:What They Mean🔑ℹ️⬇️
Essential Tech Acronyms Unveiled: What They Mean Acronyms Explained: 1. GPS: Global Positioning System – A navigation system that uses satellite signals to determine a location. 2. KYC: Know Your Customer – A process for verifying the identity of clients in financial services. 3. PDF: Po
RoadToRiches

RoadToRiches

30 likes

Data Analyst - Start a career today
1. Master Essential Tools and Skills - Why It’s Crucial: Employers prioritize technical proficiency for handling and visualizing data. - Focus Areas: - Excel: For basic data analysis and pivot tables. - SQL: To query and manage large datasets (a must-have skill). - Python/
vedha | career tips (tech) 👩‍

vedha | career tips (tech) 👩‍

219 likes

What You need to know about SQL in Tech Roles
Everyone talks about how essential SQL is for landing tech roles—whether it’s data analysis, engineering, or even marketing analytics. But here’s the part they don’t emphasize enough: Practice is KING. It’s not just about learning SQL syntax or watching tutorials; it’s about doing the work—runni
NeLo

NeLo

42 likes

A list titled "BEST YOUTUBE CHANNELS TO LEARN..." featuring various tech topics like Cybersecurity, Python, React, JavaScript, Java, DevOps, Blockchain, AI/ML, Web Development, AWS, Swift, SQL, DBMS, Ruby, Scala, SAP, C, R, jQuery, C#, .NET, Kotlin, Flutter, Laravel, and PHP, each paired with a recommended YouTube channel. The image includes a YouTube logo and the handle @securitytrybe.
Top YouTube Channels for Tech Mastery 🔑ℹ️⬇️
Unlock Your Tech Potential: The Best YouTube Channels for Learning Ever felt like the world of tech is just out of reach? Whether you’re diving into cybersecurity or mastering the nuances of UI/UX design, these YouTube channels will guide you every step of the way. Let’s break down the best reso
RoadToRiches

RoadToRiches

85 likes

A woman with dreadlocks smiles, looking right, with the text "SQL TIPS FOR BEGINNERS" overlaid in yellow. The bottom left corner shows "Lemon8 @nelo.omah".
A woman with dreadlocks smiles, looking right, with a social media post overlay stating: "SQL isn't about just databases. It's about asking the right questions to find the right answers." "Lemon8 @nelo.omah" is in the bottom left.
A woman with dreadlocks smiles, looking right, with a social media post overlay stating: "By framing queries effectively, you can uncover patterns, trends, and answers that drive decision-making. Mastering SQL means mastering the art of data-driven problem-solving." "Lemon8 @nelo.omah" is in the bottom left.
SQL Tips: Are You asking The Right Questions?
Caption During my early years of learning data analytics, I discovered that SQL is more than just a tool for working with databases. It's about asking the right questions to uncover valuable insights. Whether you're analyzing sales trends, customer behavior, or operational data, the
NeLo

NeLo

34 likes

Excel Guide
#excelspreadsheets #
FWSbeautybar

FWSbeautybar

6 likes

12 Google Gemini Tools for Creators & Growth
12 Real Ways Google Gemini Helps You Grow Online Without Feeling Burnt Out AI tools can feel overwhelming But Google Gemini actually makes life easier Especially if you’re trying to grow online Create content Build a digital product Or just stop doing everything the hard way This post br
fig3lvls

fig3lvls

480 likes

HEALTHCARE WFH WITHOUT BEING A NURSE 😭 #workfromhomejobs #remotejobs #wfhjobs #dataentryjobs #remoteworkfromhomejobs
Arialle Tate

Arialle Tate

26 likes

buliding strong Arms with Rhea Ripley 2018
Carlie Reuter

Carlie Reuter

24 likes

A book cover for 'Orchid's Query: The Ultimate Fight for Love' by Jas B., featuring a man with braids and tattoos. Overlays include 'Book Vibes', 'Good read', 'FIGHT SPORT', and 'kindleunlimited', indicating a romance book recommendation.
Orchid’s Query🌸
I love books where the smut adds flavor to the storyline instead of being the center of the story if you know what I mean.! And Jas B. Executes it very well each time. I enjoyed this read. Took only a day to eat it right on up 😂 Query is now apart of my list of book bae’s because honestly he almost
Fran🩷

Fran🩷

6 likes

A book cover titled "MASTERING SQL The Ultimate Guide to Structured Query Language" by Dana Bradshaw, featuring glowing blue server-like graphics on a dark background. A Lemon8 watermark is visible.
let me help strengthen your technical skills etc!
After 27+ years in the industry, I’m thrilled to announce the release of my new book: "Mastering SQL: The Ultimate Guide to Structured Query Language" Throughout my journey, I’ve learned the ins and outs of SQL and witnessed its transformative power in data management. Now, it's time
beingme

beingme

3 likes

Traditional RAG vs Graph RAG explained in 60 seconds by Nacho Martínez ⚡ (Data Scientist Advocate @Oracle ) 💡 Both pull external knowledge into an LLM. The difference is whether what comes back is isolated, or actually connected. Traditional RAG chunks your docs, vectorizes each chunk, simila
lindavivah

lindavivah

0 likes

✨ Tips ✨ for Building A Community on L8
Sharing My Lemon8 Journey!! Joined : 7/8/23 12/26/23 : 2000 12/29/23 : 2500 01/02/24 : 3000 01/03/24 : 3500 01/05/24 : 4000 01/13/24 : 4500 01/14/24 : 5000 01/16/24 : 5500 01/18/24 : 6000 01/20/24 : 6500 01/21/24 : 7000 01/23/24 : 7500 01/26/24 : 8000 01/29/24 : 8500 01/30/24 : 9
TheHappyPlanner

TheHappyPlanner

102 likes

🕰️ The Seven Lights — Part 365: Gravity Set Free 🌒 #TheSevenLights #7Lts #EpicF
🕰️ The Seven Lights — Part 365: Gravity Set Free 🌒 The system broke its silence, not with a command, but with a question. ✨️ True strength is found the moment we trade absolute control for the depth of understanding. #TheSevenLights #SevenLights #EpicFantasy #LivingLoom #ThePowerO
AlfredoLevelUp

AlfredoLevelUp

1 like

nuclear careers
What kinds of jobs are available in nuclear energy? #career
I love science!

I love science!

1 like

A grid showcasing 45 different ChatGPT plugins, each with an icon, name, and a brief description of its function, categorized for various uses like productivity, shopping, travel, and more.
A list of ChatGPT plugins under 'Productivity & Communication', including Slack, Zapier, To-Do, Speechki, Send Email, and Portfolio Pilot, with their respective functions.
A list of ChatGPT plugins under 'Travel & Lifestyle', including Expedia, KAYAK, Vogue, Instacart, Redfin, and Hauling Buddies, with their respective functions.
45 Mind-Blowing ChatGPT Plugins to Supercharge You
Hey everyone! 🌟 Today, I’m excited to share a list of 45 incredible ChatGPT plugins that can take your AI experience to the next level. Whether you’re looking to boost productivity, plan trips, or explore new tech tools, there’s something for everyone. Let’s dive in! 🌍 ---- Productivity & Com
Valder

Valder

115 likes

Love💛✨ #etherealkra
Kra'

Kra'

1 like

An infographic titled 'HOW DOES GOOGLE TRACKS YOU?' listing various Google services like Chrome, YouTube, Photos, Calendar, Ads, Shopping, Hangouts, Mail, Searches, Drive, News, and Maps, along with the types of user data each service tracks.
An infographic titled 'Websites You might not know.' highlighting three lesser-known Google tools: Google Scholar for academic research, Google Sky for exploring the universe, and Google Trends for analyzing search term popularity.
A list of 'GOOGLE Free Courses With Certificates' including Digital Marketing, Artificial Intelligence, Data Science, Data Analysis, Machine Learning, Google Analytics, and Google Display Campaign, each with a corresponding icon.
How Google Impacts Your Life: Learning + Insights🍋
Insights, Resources, and Learning Opportunities Google has embedded itself deeply into our daily lives, from searching for quick facts to planning entire projects. With its vast ecosystem of tools, tracking capabilities, and free educational resources, it’s more than just a search engine—it’s a
Draven Royce

Draven Royce

9 likes

marissachsos⚛️

marissachsos⚛️

11 likes

realgetawaycar

realgetawaycar

1 like

SQL interview question #11
Here's a standard sql interview question to join two tables. #sql #analyst #dataanalytics
Brandon - Analytics Mentor

Brandon - Analytics Mentor

1 like

Vasquez ✨

Vasquez ✨

1 like

Thieves have stolen “priceless” jewelry from the Louvre in Paris, the world’s most-visited museum, in an audacious seven-minute raid, the French interior minister has said. #cnn #news #paris #france #fyp
kqstla

kqstla

0 likes

Ace SQL Interview with These Steps
If you're interested in SQL here are 5 tips to help you prepare for your next SQL interview ✨Master the Basics: Solid understanding of SQL fundamentals like SELECT, JOINS, GROUP BY, and WHERE is crucial. ✨Practice Complex Queries: Focus on writing multi-join queries, subqueries, and CTEs to
NeLo

NeLo

9 likes

A woman in a yellow shirt works on a laptop, with a black handbag beside her. Text asks, 'What is one Technology that is recommended for beginners and will Always be Relevant.'
The woman smiles at the camera, with a laptop and handbag visible. Text states, 'If you're new to the tech world... here is my top pick!' An arrow points right.
The woman points upwards, revealing 'SQL Structured Query Language' as the recommended technology. Text also says 'Read the Caption' with a pointing finger emoji.
SQL REMAINS RELEVANT
When I first started learning about tech, one of the best pieces of advice I got was to learn SQL. Honestly, it was a game-changer. SQL is one of those technologies that’s beginner-friendly yet powerful enough to stay relevant no matter how advanced you get in your career. It’s used everywhere,
NeLo

NeLo

5 likes

Behind Every Smear Campaign Is a Pseudonym👤 Funded by the People of Florida!🍊 TREADBACK.com Link in bio. Matt The Welder = Matthew Taylor #mattthewelder #Florida #floridapolitics #politics #floridaman
Matt The Welder

Matt The Welder

1 like

quantum mechanics and virtual particles
Virtual particles from the uncertainty principle #quantum #physics
I love science!

I love science!

3 likes

See more