2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

条件によるgroup byを行ってそれぞれ件数を表示

Last updated at Posted at 2015-06-12

例)有効期限内と期限切れそれぞれの件数を1SQLで求めたい


mysql> select (expires_at < now()) expired, count(\*) from token group by (expires_at < now());
+---------+----------+
| expired | count(*) |
+---------+----------+
|       0 |    57824 | ※期限内
|       1 |   271056 | ※期限切れ
+---------+----------+
2 rows in set (0.14 sec)
2
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
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?