Let’s Use Spreadsheet Query Function (3) SELECT Clause

クエリイメージ Spreadsheet
この記事は約4分で読めます。
Advertisements

Target Readers

  • who are interested in SQL, but who are troublesome to prepare the environment and data from scratch
  • who are extracting data with vlookup, but who feel the limit
  • who want to analyze data
  • Even non-programmers who want to use queries
  • who are asking queries delicious? (meaning that the query is delicious)

Query function series planned (planned)

  1. Outline and purpose
  2. Syntax of query function
  3. Basic SELECT clause (get all, get only specific columns)← this time
  4. Extraction basics Try using WHERE clause (numerical value match, size, date match, size etc.)
  5. Try using the GROUP BY clause
  6. Let’s bring data from another sheet ~ Combination with ImportRange function ~
  7. Sorting basics ORDER BY clause
  8. Required if you do SQL Try a subquery
  9. There are line breaks in the data. contains/starts with helps when you can’t handle like

Query function:Basic SELECT Clause

We will publish the original data on the URL for future use. This data is identical to the sample published in the Google Visualization API.(https://developers.google.com/chart/interactive/docs/querylanguage#Select

参考用元データ

Get only one specific column

To get only column A

=QUERY(data ,"SELECT A")

If you specify Column after SELECT, you can get only the row data of that column.

Get multiple columns

in case of acquiring columns A, B, D

=QUERY(data ,"SELECT A, B, D")

If you specify after the SELECT, separated by commas, they are displayed in the specified order.

select A.B.D

If you change the order of the columns after SELECT, you can change the order of the displayed data.

=QUERY(data ,"SELECT D, A, B")
select D,A,B

By the way, if multiple same columns are specified as below, an error will occur.

=QUERY(data ,"SELECT D, A, B, D")  #Error

Get All

=QUERY(data ,"SELECT *")

Means all in the select statement, and if you make it as above, you can get all the data

I think that I will not use it much, but I can get all even if I do not set the query.

=QUERY(data,)

Summary

We looked at SELECT, which is the most basic of queries.

The basis of extraction is to first decide which column data is used in the target data from which data is extracted.

I think that the SELECT statement is not difficult, so please familiarize yourself with it.

Series: Let’s Use Spreadsheet Query Function

While not studying SQL, I will become accustomed to using the spreadsheet query function. We will study from the simple usage of select statement, including the difference from SQL.

  1. Let’s Use Spreadsheet Query Function (1) Outline and Purpose
  2. Let’s Use Spreadsheet Query Function (2) Structure of query function
  3. Let’s Use Spreadsheet Query Function (3) SELECT Clause
  4. Let’s Use Spreadsheet Query Function (4) WHERE Clause
  5. Let’s Use Spreadsheet Query Function (5) Group by
  6. Let’s Use Spreadsheet Query Function (6) Let’s bring data from another sheet ~ Combination with ImportRange function ~
  7. Let’s Use Spreadsheet Query Function (7) Sorting basics “ORDER BY” clause
  8. Let’s Use Spreadsheet Query Function (8)Required if you do SQL!! Try a subquery with the Query function
  9. Let’s Use Spreadsheet Query Function (9)line breaks in the data etc. Query function error countermeasures

コメント