| |

VerySource

 Forgot password?
 Register
Search
View: 761|Reply: 6

Find the sum of the SQL statements

[Copy link]

1

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-3-15 12:00:01
| Show all posts |Read mode
The table is as follows
A 20
B 10
A 5
B 10
A 30

The query is required to produce the following results, how to write the sentence:
A 55
B 20
Reply

Use magic Report

0

Threads

100

Posts

53.00

Credits

Newbie

Rank: 1

Credits
53.00

 China

Post time: 2020-6-13 13:00:01
| Show all posts
select A,sum (field 2) from table group by A
Reply

Use magic Report

0

Threads

100

Posts

53.00

Credits

Newbie

Rank: 1

Credits
53.00

 China

Post time: 2020-6-13 13:30:01
| Show all posts
select field 1, sum(isnull(field 2, 0)) from table group by field 1
Reply

Use magic Report

0

Threads

88

Posts

55.00

Credits

Newbie

Rank: 1

Credits
55.00

 China

Post time: 2020-6-13 17:00:01
| Show all posts
select c1,sum(c2) field 2
from tablename
group by c1
Reply

Use magic Report

0

Threads

211

Posts

108.00

Credits

Newbie

Rank: 1

Credits
108.00

 China

Post time: 2020-6-13 21:30:01
| Show all posts
select col1, col2=sum(col2) from tbName group by col1
Reply

Use magic Report

0

Threads

40

Posts

29.00

Credits

Newbie

Rank: 1

Credits
29.00

 United States

Post time: 2020-6-13 23:00:01
| Show all posts
select field 1, sum (field 2)
from table
group by A
Reply

Use magic Report

0

Threads

40

Posts

29.00

Credits

Newbie

Rank: 1

Credits
29.00

 China

Post time: 2020-6-14 09:15:01
| Show all posts
select field 1, sum(isnull (field 2, 0)
from table
group by field 1
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list