質問編集履歴

10

2017/12/13 03:29

投稿

dera
dera

スコア28

test CHANGED
File without changes
test CHANGED
@@ -14,6 +14,8 @@
14
14
 
15
15
 
16
16
 
17
+
18
+
17
19
  現状は、
18
20
 
19
21
  a b c
@@ -22,7 +24,7 @@
22
24
 
23
25
  01 3 1
24
26
 
25
- というがあり
27
+ というブルAがあり
26
28
 
27
29
  aはvarchar、b,cはnumericです。
28
30
 
@@ -37,6 +39,8 @@
37
39
  sum(coalesce(a,0)+
38
40
 
39
41
  coalesce(b,0))
42
+
43
+ from A
40
44
 
41
45
  group by a
42
46
 

9

2017/12/13 03:29

投稿

dera
dera

スコア28

test CHANGED
File without changes
test CHANGED
@@ -14,36 +14,62 @@
14
14
 
15
15
 
16
16
 
17
- 例えば
17
+ 現状は
18
+
19
+ a b c
20
+
21
+ 01 2 3
22
+
23
+ 01 3 1
24
+
25
+ というデータがあり
26
+
27
+ aはvarchar、b,cはnumericです。
18
28
 
19
29
 
20
30
 
21
- a b c
22
-
23
- 01 2 3
31
+ sqlは
24
-
25
- 01 4 1
26
32
 
27
33
 
28
34
 
35
+ select a,
36
+
37
+ sum(coalesce(a,0)+
38
+
29
- というデータがあった時、
39
+ coalesce(b,0))
40
+
41
+ group by a
42
+
43
+
44
+
45
+ としています。
46
+
47
+
48
+
49
+ 結果は、
30
50
 
31
51
 
32
52
 
33
53
  a
34
54
 
35
- 01 10
55
+ 01 9
36
56
 
37
57
 
38
58
 
39
- なるのが現状なのですが
59
+ このようになるのですが
40
60
 
41
61
 
42
62
 
43
- a b c
63
+ a b c
44
64
 
45
- 01 6 4
65
+ 01 5 4
46
66
 
47
67
 
48
68
 
69
+ としたいです。
70
+
71
+
72
+
49
- とするにはのよなSQLを書けばよろしいでしょうか?ご教示お願いします
73
+ どうすればよろしいでしょうか。
74
+
75
+ ご教示お願いします。

8

2017/12/13 03:27

投稿

dera
dera

スコア28

test CHANGED
File without changes
test CHANGED
@@ -18,7 +18,7 @@
18
18
 
19
19
 
20
20
 
21
- a b c
21
+ a b c
22
22
 
23
23
  01 2 3
24
24
 
@@ -27,3 +27,23 @@
27
27
 
28
28
 
29
29
  というデータがあった時、
30
+
31
+
32
+
33
+ a
34
+
35
+ 01 10
36
+
37
+
38
+
39
+ となるのが現状なのですが、
40
+
41
+
42
+
43
+ a b c
44
+
45
+ 01 6 4
46
+
47
+
48
+
49
+ とするにはどのようなSQLを書けばよろしいでしょうか?ご教示お願いします。

7

2017/12/13 02:58

投稿

dera
dera

スコア28

test CHANGED
File without changes
test CHANGED
@@ -23,3 +23,7 @@
23
23
  01 2 3
24
24
 
25
25
  01 4 1
26
+
27
+
28
+
29
+ というデータがあった時、

6

2017/12/13 02:56

投稿

dera
dera

スコア28

test CHANGED
File without changes
test CHANGED
@@ -21,3 +21,5 @@
21
21
  a b c
22
22
 
23
23
  01 2 3
24
+
25
+ 01 4 1

5

2017/12/13 02:56

投稿

dera
dera

スコア28

test CHANGED
File without changes
test CHANGED
@@ -20,4 +20,4 @@
20
20
 
21
21
  a b c
22
22
 
23
-
23
+ 01 2 3

4

2017/12/13 02:56

投稿

dera
dera

スコア28

test CHANGED
File without changes
test CHANGED
File without changes

3

2017/12/13 02:55

投稿

dera
dera

スコア28

test CHANGED
File without changes
test CHANGED
@@ -21,5 +21,3 @@
21
21
  a b c
22
22
 
23
23
 
24
-
25
- a

2

2017/12/13 02:54

投稿

dera
dera

スコア28

test CHANGED
File without changes
test CHANGED
@@ -21,3 +21,5 @@
21
21
  a b c
22
22
 
23
23
 
24
+
25
+ a

1

2017/12/13 02:54

投稿

dera
dera

スコア28

test CHANGED
File without changes
test CHANGED
File without changes