Home > database >  Master genuflect is begged, be urgent! Be urgent! Be urgent!
Master genuflect is begged, be urgent! Be urgent! Be urgent!

Time:09-27


The select t. conductors,
T. refund,
The sum (t) as the number of
The sum (price + t. t. affair fee) as amount,
T. mark
The from
Ticket table t
Where to_char (t. ticket time, 'MMDD)=' 1118 'and t. sign in (0, 3)
Group by t. conductors,
T. refund,
T. mark
Results:
1 zmh1 zmh1 1 8 3
2 zmh1 Liu Shu 1 8 3
3 zmh1 4 32 0

As statistics together, I am going to put the conductor zmh1 should be 5 people, the amount of money at the same time, the conductor is 40 and refund part will separate
Ask ace to see how to do?????

CodePudding user response:

A little blurred, the table structure and part of the data and the results listed,

CodePudding user response:

The
refer to the original poster scybwlylyj response:

The select t. conductors,
T. refund,
The sum (t) as the number of
The sum (price + t. t. affair fee) as amount,
T. mark
The from
Ticket table t
Where to_char (t. ticket time, 'MMDD)=' 1118 'and t. sign in (0, 3)
Group by t. conductors,
.

SQL written about in this way, in the datawindow reprocessing can reach the effect you want

CodePudding user response:

 
-- -- the conductor of SQL
The select t. conductors,
The sum (t) as the number of
The sum (price + t. t. affair fee) as amount
The from ticket table t
Where to_char (t. ticket time, 'MMDD)=' 1118 'and t. sign in (0, 3)
Group by t. conductor

-- -- refund part of SQL
The select t. refund,
The sum (t) as the number of
The sum (price + t. t. affair fee) as amount
The from ticket table t
Where to_char (t. ticket time, 'MMDD)=' 1118 'and t. sign in (0, 3)
Group by t. part refund

- according to the sign grouping of SQL
The select t. logo,
The sum (t) as the number of
The sum (price + t. t. affair fee) as amount
The from ticket table t
Where to_char (t. ticket time, 'MMDD)=' 1118 'and t. sign in (0, 3)
Group by t. mark

Your needs some fuzzy, not hierarchical relationships in different groups, so can only help you to organize a group layer of SQL, if you have multiple packet, please describe hierarchical relationships, for example: according to the first flag group, under the same flag by grouping the conductor, and then according to the ticket agent groups, namely group according to the sale member and refund part grouping is not appropriate for the level of the SQL logic,

CodePudding user response:

Looked at one, in Chinese,
  • Related