select * from total_point h1 order by total_point;
id | total_point | point_count | up_date
----+-------------+-------------+-------------------------------
3 | 50000 | 1 | 2006-04-07 15:25:02.013991+09
2 | 60000 | 2 | 2006-04-07 14:54:27.018996+09
4 | 80000 | 1 | 2006-04-07 15:38:40.411232+09
(3 rows)
point_countの数値だけをある条件で抽出して、その値をすべて足すときは
どうすればいいのでしょうか??
select point_count from total_point h1 where total_point > '50000' order by total_point;
point_count
-------------
2
1
(2 rows)
で、3という値が取得できれば問題ありません。
select SUM(point_count) from total_point h1 where total_point > '50000';
SUMを使ったらいいでしょう。
あと order by は 不要になりますね。
ありがとうございます。
後、他にもなんですか以下のSQLを実行して
zyun | total_point | point_count
------+-------------+-------------
3 | 50000 | 3
2 | 60000 | 3
1 | 80000 | 1
zyunというフィールドで3となって値を
前のレコードのpoint_countを足して
zyunというフィールドの値を
5にしたいのですがどうしたらいいかわかりますか??