| |

VerySource

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

Seeking a basic sql

[Copy link]

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-12-17 14:30:01
| Show all posts |Read mode
table a,b,c


a column da,name in the table
b column in table da,acc
c column acc,je

Among them, column da of table a = column da of table b
acc column of table b = acc column of table c

Want now

a.da,a.name ,sum(c.je) such a result

Such as


001 three 100
002 Li Si 87
003 King Five 94
...
...
...

Please expert advice. How to write this sql
Thank you.
Reply

Use magic Report

0

Threads

49

Posts

35.00

Credits

Newbie

Rank: 1

Credits
35.00

 China

Post time: 2020-12-17 19:30:01
| Show all posts
select a.da,a.name ,sum(c.je)
from a inner join b on a.da = b.da
       inner join c on b.acc = c.acc
Reply

Use magic Report

0

Threads

5

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-12-17 20:00:01
| Show all posts
select a.da,a.name ,sum(c.je)
from a
left join b on a.da = b.da
left join c on c.acc = b.acc
Reply

Use magic Report

0

Threads

88

Posts

55.00

Credits

Newbie

Rank: 1

Credits
55.00

 Great Britain

Post time: 2020-12-17 21:15:01
| Show all posts
select a.da,a.name ,sum(c.je)
from a, b, c
where a.da = b.da and b.acc = c.acc
Reply

Use magic Report

0

Threads

8

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

Post time: 2020-12-19 09:00:01
| Show all posts
select a.da,a.name ,sum(c.je) as je
from a inner join b on a.da = b.da
       inner join c on b.acc = c.acc
Reply

Use magic Report

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

 Author| Post time: 2020-12-19 18:45:01
| Show all posts
I have tried the grammar of the eldest brothers upstairs
a.da is invalid in the select list because the column is not included in the aggregate function. And there is no group by statement

(Note, a is a view, and a view contains da column)
Reply

Use magic Report

0

Threads

5

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-12-19 23:45:02
| Show all posts
select a.da,a.name ,sum(c.je)
from a
left join b on a.da = b.da
left join c on c.acc = b.acc
group by a.da,a.name
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-12-20 03:45:01
| Show all posts
select a.da, a.name, T1.je from
a inner join
(
select b.da, sum(c.je) as je
from b inner join c on b.acc = c.acc group by b.acc, b.acc
) AS T1
on a.da = T1.da
Reply

Use magic Report

1

Threads

5

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-12-20 06:30:02
| Show all posts
select a.da,a.name,sum(c.je)
from a ,b ,c
where a.da = b.da and b.acc = c.acc
Reply

Use magic Report

1

Threads

5

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-12-20 07:15:01
| Show all posts
select a.da,a.name,sum(c.je)
from a ,b ,c
where a.da = b.da and b.acc = c.acc
group by a.da,a.name
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