| |

VerySource

 Forgot password?
 Register
Search
View: 1094|Reply: 5

How to take out the values ​​in one table by year and month and add them to calculate in another table ???

[Copy link]

1

Threads

2

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-1-6 08:10:01
| Show all posts |Read mode
One table stores data, and the other table calculates the records of the first table and displays them

The calculation should be automatically calculated on a year-by-month basis, I will not engage in it, I hope everyone will give pointers!
Reply

Use magic Report

1

Threads

2

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

 Author| Post time: 2020-1-6 09:12:01
| Show all posts
When the data in the first table is stored, each record is dated when it is stored
Reply

Use magic Report

0

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 Norway

Post time: 2020-1-6 19:03:01
| Show all posts
Is it a group?
You can use the GROUP BY clause.
Reply

Use magic Report

1

Threads

19

Posts

14.00

Credits

Newbie

Rank: 1

Credits
14.00

 China

Post time: 2020-1-20 15:18:02
| Show all posts
Write down the two table structures, and then write out your requirements, I will write for you
Reply

Use magic Report

0

Threads

18

Posts

17.00

Credits

Newbie

Rank: 1

Credits
17.00

 Singapore

Post time: 2020-1-31 08:27:01
| Show all posts
I don't know if it's right, my understanding is limited, and I will answer according to my own understanding.

If the first table is data, the second table recommends that you do not make a table, it is more appropriate to make a View.

If the first table uses year and month as the standard for grouping, you can use six bytes of character data to represent the year and month, such as:

YearMonth C (6) // '200602' or directly use date data {^ 2007-02-01}, the following can be created

A View

  Create View second table As;
    Select YearMonth, Count (YearMonth) As Counts, Sum (Total) As Totals;
    From the first table Group By YearMonth

Then open this view at any time, and you can dynamically get the relevant data in the first table at any time.
Reply

Use magic Report

0

Threads

32

Posts

23.00

Credits

Newbie

Rank: 1

Credits
23.00

 China

Post time: 2020-2-21 08:45:02
| Show all posts
Write down the two table structures, and then write your requirements and results
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