LoginSignup
0
1

More than 3 years have passed since last update.

【SQL入門】COUNT(*) と COUNT(カラム名) の違い

Last updated at Posted at 2020-08-17

COUNT関数

SQLにおける集計関数のひとつ。
該当した行数を取得する関数。

-- genre が 'アクション' である行数を数える
SELECT COUNT(*) FROM movie WHERE genre = 'アクション';

COUNT(*) と COUNT(カラム名) の違い

  • COUNT(*)は、単純に行数をカウントする( NULL の行も含める)。
  • COUNT(カラム名) は、指定カラムの値が NULL である行を無視してカウントする。

参考図書:スッキリわかるSQL入門 第2版

0
1
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
1