mysql:8559
From: UNO Shintaro <UNO Shintaro <uno@xxxxxxxxxx>>
Date: Wed, 07 Jan 2004 04:59:28 +0900
Subject: [mysql 08559] Re: count(*) の合計の仕方
>(SELECT code1 as code FROM test1 where code1 between 'c555' and 'd998' ) >UNION ALL (SELECT code2 as code FROM test1 where code2 between 'c555' and 'd998') >UNION ALL (SELECT code3 as code FROM test1 where code3 between 'c555' and 'd998') >UNION ALL (SELECT code4 as code FROM test1 where code4 between 'c555' and 'd998') >UNION ALL (SELECT code5 as code FROM test1 where code5 between 'c555' and 'd998') > そこで、これらの結果から、合計数5のみを求め、表示したいのです。 これでどうですか。 SELECT SUM(IF(code1 between 'c555' and 'd998',1,0)) + SUM(IF(code2 between 'c555' and 'd998',1,0)) + SUM(IF(code3 between 'c555' and 'd998',1,0)) + SUM(IF(code4 between 'c555' and 'd998',1,0)) + SUM(IF(code5 between 'c555' and 'd998',1,0)) AS total_count FROM test1 -- UNO Shintaro, 宇野 信太郎 mailto:uno@xxxxxxxxxx http://www.venus.dti.ne.jp/~uno/
8558 2004-01-07 02:39 [zai <zai91210@xxxxxx] count(*) の合計の仕方 -> 8559 2004-01-07 04:59 ┣[UNO Shintaro <uno@xx] 8561 2004-01-07 15:29 ┃┗[zai <zai91210@xxxxxx] 8562 2004-01-07 15:56 ┃ ┣[<lavlav@xxxxxxxxxx> ] 8563 2004-01-07 16:00 ┃ ┃┗[<lavlav@xxxxxxxxxx> ] 8565 2004-01-07 16:37 ┃ ┗[ML account <ml@xxxxx] 8566 2004-01-07 16:46 ┃ ┗[ML account <ml@xxxxx] 8564 2004-01-07 16:22 ┣[Kazuhiro Yoshida <mo] 8790 2004-02-14 01:48 ┗[zai <zai91210@xxxxxx] 機種の変更に伴う不具合 8791 2004-02-14 15:43 ┣[Seto <seto@xxxxxxxxx] 8792 2004-02-14 20:09 ┣[<konet218@xxxxxxxxxx] 8793 2004-02-15 03:21 ┃┗[zai <zai91210@xxxxxx] 8794 2004-02-15 03:43 ┃ ┣[<konet218@xxxxxxxxxx] 8816 2004-02-19 05:35 ┃ ┃┗[zai <zai91210@xxxxxx] 8796 2004-02-15 06:28 ┃ ┗[Seto <seto@xxxxxxxxx] 8818 2004-02-19 06:35 ┃ ┗[zai <zai91210@xxxxxx] 8795 2004-02-15 04:18 ┗[とみたまさひろ <tomm] 8817 2004-02-19 06:26 ┗[zai <zai91210@xxxxxx] 8819 2004-02-19 09:47 ┣[Seto <seto@xxxxxxxxx] 8820 2004-02-19 15:29 ┃┣[<lavlav@xxxxxxxxxx> ] 8824 2004-02-19 21:12 ┃┃┗[zai <zai91210@xxxxxx] 8823 2004-02-19 21:02 ┃┗[zai <zai91210@xxxxxx] 8826 2004-02-19 21:57 ┃ ┗[bon <bon@xxxxxxxxxx>] 8827 2004-02-20 02:19 ┃ ┗[zai <zai91210@xxxxxx] 8821 2004-02-19 18:52 ┗[Hiroto Tsubaki <jak@] 8825 2004-02-19 21:46 ┗[zai <zai91210@xxxxxx] Re: 機種の変更に伴う不具合(大感謝)