0

この列は sqlite の価格です。私が使用しSELECT SUM(price) FROM example; ていますが、値が正しくありません。5 桁の数字の後に 67 の数字と 6 つのゼロと 1 が続きます。例: 34,456.670000001 。列は VARCHAR として作成されます。numeric(100) と Integer を試しましたが、値は同じままです。私は db の初心者なので、ガイドしてください。ありがとうございます。助けていただければ幸いです。

345,887.21
16,520.11 
388,902.02 
24,622.43 
278,916.52 
42.22 
17,234.01 
377,245.67 
5,104,245.00 
23,332.98 
126,875.21 
5,112,225.14 
4,552.54 
402.82 
132,875.32 
126,334,123.32 
345,887.21
16,520.11 
388,902.02 
24,622.43 
278,916.52 
42.22 
17,234.01 
377,245.67 
5,104,245.00 
23,332.98 
126,875.21 
5,112,225.14 
4,552.54 
402.82 
132,875.32 
75,334,123.32 
345,887.21
16,520.11 
388,902.02 
24,622.43 
278,916.52 
42.22 
17,234.01 
377,245.67 
5,104,245.00 
23,332.98 
126,875.21 
5,112,225.14 
4,552.54 
402.82 
132,875.32 
52,334,123.32 
2,442,887.21
255,165.11 
3,889.02 
622.43 
916.52 
42.22 
17,234.01 
77,245.67 
104,245.00 
332.98 
6,875.21 
12,225.14 
52.54 
402.82 
32,875.32 
160,334,123.32 
345,887.21
16,520.11 
388,902.02 
24,622.43 
278,916.52 
42.22 
17,234.01 
377,245.67 
5,104,245.00 
23,332.98 
126,875.21 
5,112,225.14 
4,552.54 
402.82 
132,875.32 
129,334,123.00 
345,887.21
16,520.11 
388,902.02 
24,622.43 
278,916.52 
42.22 
17,234.01 
377,245.67 
5,104,245.00 
23,332.98 
126,875.21 
5,112,225.14 
4,552.54 
402.82 
132,875.32 
129,334,123.32 
345,887.21
16,520.11 
388,902.02 
24,622.43 
278,916.52 
42.22 
17,234.01 
377,245.67 
5,104,245.00 
23,332.98 
126,875.21 
5,112,225.14 
4,552.54 
402.82 
132,875.32 
129,334,123.32 
2,442,887.21
255,165.11 
3,889.02 
622.43 
916.52 
42.22 
17,234.01 
77,245.67 
104,245.00 
332.98 
6,875.21 
12,225.14 
52.54 
402.82 
32,875.32 
246,323,743.32 
345,887.45
16,520.11 
388,902.02 
24,622.43 
278,916.52 
42.22 
17,234.01 
377,245.67 
5,104,245.00 
23,332.98 
126,875.21 
5,112,225.14 
4,552.54 
402.82 
132,875.32 
129,334,123.32 
345,887.21
16,520.11 
388,902.02 
24,622.43 
278,916.52 
42.22 
17,234.01 
377,245.67 
5,104,245.00 
23,332.98 
126,875.21 
5,112,225.14 
4,552.54 
402.82 
132,875.32 
129,237,129.57 
345,887.21
16,520.11 
388,902.02 
24,622.43 
278,916.52 
42.22 
17,234.01 
377,245.67 
5,104,245.00 
23,332.98 
126,875.21 
5,112,225.14 
4,552.54 
402.82 
132,875.32 
129,334,123.32 
2,442,887.21
255,165.11 
3,889.02 
622.43 
916.52 
42.22 
17,234.01 
77,245.67 
104,245.00 
332.98 
6,875.21 
12,225.14 
52.54 
402.82 
32,875.32 
183,334,123.32 
345,887.21
16,520.11 
388,902.02 
24,622.43 
278,916.52 
42.22 
17,234.01 
377,245.67 
5,104,245.00 
23,332.98 
126,875.21 
5,112,225.14 
4,552.54 
402.82 
132,875.32 
129,322,555.39 
345,887.21
16,520.11 
388,902.02 
24,622.43 
278,916.52 
42.22 
17,234.01 
377,245.67 
5,104,245.00 
23,332.98 
126,875.21 
5,112,225.14 
4,552.54 
402.82 
132,875.32 
129,334,123.32 
345,887.21
16,520.11 
388,902.02 
24,622.43 
278,916.52 
42.22 
17,234.01 
377,245.67 
5,104,245.00 
23,332.98 
126,875.21 
5,112,225.14 
4,552.54 
402.82 
132,875.32 
129,334,123.32 
2,442,887.21
255,165.11 
3,889.02 
622.43 
916.52 
42.22 
17,234.01 
77,245.67 
104,245.00 
332.98 
6,875.21 
12,225.14 
52.54 
402.82 
32,875.32 
153,334,123.32 
345,887.21
16,520.11 
388,902.02 
24,622.43 
278,916.52 
42.22 
17,234.01 
377,245.67 
5,104,245.00 
23,332.98 
126,875.21 
5,112,225.14 
4,552.54 
402.82 
132,875.32 
129,400,321.23 
345,887.21
16,520.11 
388,902.02 
24,622.43 
278,916.52 
42.22 
17,234.01 
377,245.67 
5,104,245.00 
23,332.98 
126,875.21 
5,112,225.14 
4,552.54 
402.82 
132,875.32 
129,334,123.32 
345,887.21
16,520.11 
388,902.02 
24,622.43 
278,916.52 
42.22 
17,234.01 
377,245.67 
5,104,245.00 
23,332.98 
126,875.21 
5,112,225.14 
4,552.54 
402.82 
132,875.32 
129,334,123.32 
2,442,887.21
255,165.11 
3,889.02 
622.43 
916.52 
42.22 
17,234.01 
77,245.67 
104,245.00 
332.98 
6,875.21 
12,225.14 
52.54 
402.82 
32,875.32 
83,334,123.32 
345,887.21
16,520.11 
388,902.02 
24,622.43 
278,916.52 
42.22 
17,234.01 
377,245.67 
5,104,245.00 
23,332.98 
126,875.21 
5,112,225.14 
4,552.54 
402.82 
132,875.32 
129,341,152.99 
345,887.21
16,520.11 
388,902.02 
24,622.43 
278,916.52 
42.22 
17,234.01 
377,245.67 
5,104,245.00 
23,332.98 
126,875.21 
5,112,225.14 
4,552.54 
402.82 
132,875.32 
129,334,123.32 
345,887.21
16,520.11 
388,902.02 
24,622.43 
278,916.52 
42.22 
17,234.01 
377,245.67 
5,104,245.00 
23,332.98 
126,875.21 
5,112,225.14 
4,552.54 
402.82 
132,875.32 
139,334,123.32 
2,442,887.21
255,165.11 
3,889.02 
622.43 
916.52 
42.22 
17,234.01 
77,245.67 
104,245.00 
332.98 
6,875.21 
12,225.14 
52.54 
402.82 
32,875.32 
164,334,123.32 
345,887.21
16,520.11 
388,902.02 
24,622.43 
278,916.52 
42.22 
17,234.01 
377,245.67 
5,104,245.00 
23,332.98 
126,875.21 
5,112,225.14 
4,552.54 
402.82 
132,875.32 
129,299,477.81 
345,887.21
16,520.11 
388,902.02 
24,622.43 
278,916.52 
42.22 
17,234.01 
377,245.67 
5,104,245.00 
23,332.98 
126,875.21 
5,112,225.14 
4,552.54 
402.82 
132,875.32 
129,334,123.32 
345,887.21
16,520.11 
388,902.02 
24,622.43 
278,916.52 
42.22 
17,234.01 
377,245.67 
5,104,245.00 
23,332.98 
126,875.21 
5,112,225.14 
4,552.54 
402.82 
132,875.32 
139,334,123.32 
2,442,887.21
255,165.11 
3,889.02 
622.43 
916.52 
42.22 
17,234.01 
77,245.67 
104,245.00 
332.98 
6,875.21 
12,225.14 
52.54 
402.82 
32,875.32 
166,334,123.32 
345,887.21
16,520.11 
388,902.02 
24,622.43 
278,916.52 
42.22 
17,234.01 
377,245.67 
5,104,245.00 
23,332.98 
126,875.21 
5,112,225.14 
4,552.54 
402.82 
132,875.32 
129,309,926.11 
345,887.21
16,520.11 
388,902.02 
24,622.43 
278,916.52 
42.22 
17,234.01 
377,245.67 
5,104,245.00 
23,332.98 
126,875.21 
5,112,225.14 
4,552.54 
402.82 
132,875.32 
129,334,123.32 
345,887.21
16,520.11 
388,902.02 
24,622.43 
278,916.52 
42.22 
17,234.01 
377,245.67 
5,104,245.00 
23,332.98 
126,875.21 
5,112,225.14 
4,552.54 
402.82 
132,875.32 
139,334,123.32 
2,442,887.21
255,165.11 
3,889.02 
622.43 
916.52 
42.22 
17,234.01 
77,245.67 
104,245.00 
332.98 
6,875.21 
12,225.14 
52.54 
402.82 
32,875.32 
83,334,123.32 
345,887.21
16,520.11 
388,902.02 
24,622.43 
278,916.52 
42.22 
17,234.01 
377,245.67 
5,104,245.00 
23,332.98 
126,875.21 
5,112,225.14 
4,552.54 
402.82 
132,875.32 
129,334,123.32 
345,887.21
16,520.11 
388,902.02 
24,622.43 
278,916.52 
42.22 
17,234.01 
377,245.67 
5,104,245.00 
23,332.98 
126,875.21 
5,112,225.14 
4,552.54 
402.82 
132,875.32 
129,387,002.55 
345,887.21
16,520.11 
388,902.02 
24,622.43 
278,916.52 
42.22 
17,234.01 
377,245.67 
5,104,245.00 
23,332.98 
126,875.21 
5,112,225.14 
4,552.54 
402.82 
132,875.32 
31,334,123.32 
2,442,887.21
255,165.11 
3,889.02 
622.43 
916.52 
42.22 
17,234.01 
77,245.67 
104,245.00 
332.98 
6,875.21 
12,225.14 
52.54 
402.82 
32,875.32 
83,334,123.32 
4

1 に答える 1

3

問題は、それらの文字列を数値に暗黙的にキャストして合計できるようにするときに、SQLite がコンマで数値を切り捨てることです。例えば:

sqlite> select '1,000' + '2,000';
'1,000' + '2,000'
3

コンマを削除するだけです。を使用replaceして、SQLite のデフォルトの型変換でそこから取得できるようにする必要があります。

SELECT SUM(replace(price, ',', '')) FROM example

例えば:

sqlite> select replace('1,000', ',', '') + replace('2,000', ',', '');
replace('1,000', ',', '') + replace('2,000', ',', '')
3000
于 2012-12-24T07:16:39.910 に答える