0
2

More than 1 year has passed since last update.

【コピペ用】スプレッドシート Query関数のよく使う書き方メモ

Last updated at Posted at 2022-12-13

はじめに

よく業務でスプレッドシートを使ってQuery関数を書くことがあるが、書き方をなかなか覚えられない・・・というか覚えることを諦めたためコピペでつかえるようによく使う記述をメモしました!

Query関数

select文とwhere文

=query('シート名'!$A:$Z,"select A,B,C where A='あいうえお'")

複数条件

かつ
=query('シート名'!$A:$Z,"select A,B,C where A='あいうえお' and B='かきくけこ'")
または
=query('シート名'!$A:$Z,"select A,B,C where A='あいうえお' or B='かきくけこ'")

条件不一致

=query('シート名'!$A:$Z,"select A,B,C where A<>'あいうえお'")
=query('シート名'!$A:$Z,"select A,B,C where not A='あいうえお'")

日付関連

いつから
=query('シート名'!$A:$Z,"select A,B,C where A>=date'2022-12-12'")
いつからいつまで
=query('シート名'!$A:$Z,"select A,B,C where A>=date'2022-01-01' and A<=date'2023-12-31'")

縦結合

=query({$A$1:$A$10;$A$15:$A$24},"select*")

横結合

=query({$A$1:$C$10,$C$15:$H$24},"select*")

Importrange

=query(importrange("スプシid","シート名!$A:$Z"),"select Col1, Col2, Col3 where Col1='あいうえお'")
アルファベットの列番号
列番号 アルファベット
1 A
2 B
3 C
4 D
5 E
6 F
7 G
8 H
9 I
10 J
11 K
12 L
13 M
14 N
15 O
16 P
17 Q
18 R
19 S
20 T
21 U
22 V
23 W
24 X
25 Y
26 Z
AA以降 +26

最後に

こちらの記事は完全コピーしていただいて構いません!
ご自身のよく使う関数のメモを作成するのに使ってみたりしてみてください^^
ご精読ありがとうございました!

0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2