| |

VerySource

 Forgot password?
 Register
Search
View: 635|Reply: 4

How to write the sql statement of the new view?

[Copy link]

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-3-5 23:00:02
| Show all posts |Read mode
Take a column of View_a from Table A, a column of View_b from Table B, and a column of View_c from Table C. According to some conditions, the result of multiplying View_b and View_c is a new column NewView_bc. Now create a new view, the column names of the view are obtained from the above: View_a, View_b, NewView_bc. How to write the sql statement of the new view?
Reply

Use magic Report

0

Threads

88

Posts

55.00

Credits

Newbie

Rank: 1

Credits
55.00

 China

Post time: 2020-5-20 19:00:01
| Show all posts
create view view_name
as

select a.View_a, b.View_b, b.View_b * c.View_c NewView_bc
from Table A a, Table B b, Table C c
where a.id = b.id and a.id = c.id

go
Reply

Use magic Report

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-5-28 05:45:02
| Show all posts
I encountered a new problem:
    There is a view A with the following contents:
OrderID JeFen
2 11
2 16
2 270
8 112200
9 2460
9 240
I want to create a new view B to count A, so that the content of B is as follows:
OrderID JeFen
2 11 + 16 + 270
8 112200
9 2460 + 240
How to write the sql statement that generates view B?
Reply

Use magic Report

0

Threads

7

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

Post time: 2020-5-29 12:00:01
| Show all posts
create view B
as
select orderid, sum (jefen) sum_jefen
from a
group by orderid
Reply

Use magic Report

0

Threads

88

Posts

55.00

Credits

Newbie

Rank: 1

Credits
55.00

 China

Post time: 2020-5-29 23:45:01
| Show all posts
create view view B
as

select orderid, sum (jefen) JeFen
from view A
group by orderid
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