掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
SQLの書き方 (ID:37596)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
select sum(age0) as 十歳未満,sum(age10) as 十台,sum(age20) as 二十台 from ( select 1 as age0, 0 as age10, 0 as age20 from table where age < 10 union all select 0 as age0, 1 as age10, 0 as age20 from table where age between 10 and 19 union all select 0 as age0, 0 as age10, 1 as age20 from table where age between 20 and 29 ) こんな感じでしょうか。 テストしてませんので、もしかしたら "1 as age0" の部分を "cast(1 as integer) as age0" のように データ型を指定しなければならないかもしれません。 (Paradoxではそうだった^^;)
←解決時は質問者本人がここをチェックしてください。
更新する
戻る
掲示板システム
Copyright 2021 Takeshi Okamoto All Rights Reserved.