| |

VerySource

 Forgot password?
 Register
Search
View: 1297|Reply: 10

Find sql summary statement

[Copy link]

5

Threads

16

Posts

10.00

Credits

Newbie

Rank: 1

Credits
10.00

 China

Post time: 2020-2-3 20:30:01
| Show all posts |Read mode
table
id jzl
1 2
2 5
3 8
4 1
5 4
6 6

The result is as follows: how many data is there in column a, and column j is the sum of jzl
a b
6 16


How to write this sentence
Reply

Use magic Report

0

Threads

49

Posts

35.00

Credits

Newbie

Rank: 1

Credits
35.00

 China

Post time: 2020-3-21 15:45:01
| Show all posts
select count (*) as a, sum (jzl) as b from table
Reply

Use magic Report

0

Threads

114

Posts

69.00

Credits

Newbie

Rank: 1

Credits
69.00

 China

Post time: 2020-3-21 16:15:01
| Show all posts
select count (*) as a, b = sum (jzl) from tablename group by id
Reply

Use magic Report

0

Threads

211

Posts

108.00

Credits

Newbie

Rank: 1

Credits
108.00

 China

Post time: 2020-3-21 22:45:01
| Show all posts
select a = (select count (*) from tbName),
b = (select sum (jzl) from tbName)
Reply

Use magic Report

0

Threads

211

Posts

108.00

Credits

Newbie

Rank: 1

Credits
108.00

 China

Post time: 2020-3-22 09:15:02
| Show all posts
create table T (id int, jzl int)
insert T select 1, 2
union all select 2, 5
union all select 3, 8
union all select 4, 1
union all select 5, 4
union all select 6, 6

select a = count (*), b = sum (jzl) from T
--result
a b
----------- -----------
6 26

(1 row (s) affected)
Reply

Use magic Report

0

Threads

14

Posts

12.00

Credits

Newbie

Rank: 1

Credits
12.00

 China

Post time: 2020-3-23 19:15:01
| Show all posts
select count (*) as a, sum (jzl) as b
from tbname
Reply

Use magic Report

0

Threads

93

Posts

46.00

Credits

Newbie

Rank: 1

Credits
46.00

 China

Post time: 2020-3-23 22:30:01
| Show all posts
select record = count (id),-record of id
sum (jzl) from table
Reply

Use magic Report

0

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-3-24 20:00:02
| Show all posts
select count (id) as a, sum (jzl) as b from a
Reply

Use magic Report

0

Threads

126

Posts

73.00

Credits

Newbie

Rank: 1

Credits
73.00

 Unknown

Post time: 2020-3-27 13:15:01
| Show all posts
They are all positive solutions. . .
Reply

Use magic Report

0

Threads

126

Posts

73.00

Credits

Newbie

Rank: 1

Credits
73.00

 China

Post time: 2020-3-27 15:15:01
| Show all posts
Except for Group. . ~-~
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