Home > Software engineering >  VB6 SQL2000 grouping statistics SQL statements
VB6 SQL2000 grouping statistics SQL statements

Time:10-15

Table TB
Date number 1 unit price 1 amount 1 number 2 unit price amount 2
The 2011-10-1 5 2 10 0 0 0
The 2011-10-2 10 20 2 0 0 0
The 2011-10-3 0 0 0 10 2 20
The 2011-11-20 10 20 2 0 0 0
The 2011-11-25 0 0 0 10 3 30
The 2012-5-1 2 0 0 0 5 10
The 2012-5-20 15 2 0 0 0 30

Want to get the result:
Date number 1 unit price 1 amount 1 number 2 unit price amount 2
The 2011-10-1 5 2 10 0 0 0
The 2011-10-2 10 20 2 0 0 0
The 2011-10-3 0 0 0 10 2 20
This month total 15 30 10 20
The 2011-11-20 10 20 2 0 0 0
The 2011-11-25 0 0 0 10 3 30
This month total 10 20 October 30
The 2012-5-1 2 0 0 0 5 10
The 2012-5-20 15 2 0 0 0 30
This month total 0 0 20 and 40

According to monthly summary, thank you to help you, (SQL statements can be run in VB6)

CodePudding user response:

You can see do not
Select * from TB
The union
Select to_char (tradedate, 'yyyy - mm), count (number 1), count (number 2),...
The from
TB
Group by to_char (tradedate, 'yyyy - mm)
The order by tradedate
To summarize the process slightly, to ensure that the summary appears behind can
Date the statements of the oracle, I wrote you instead of SQL Server,

If you don't come out, give me the build table statements, I give you raised out in oracle,

CodePudding user response:

Thank teacher upstairs,
If there is no other way, also have to think of a stupid way to
  • Related