Summation by groups and subgroups

I have a report on crystals, it has a group operator based on two fields

  • COMPANYNAME
  • Account type

The Crystal Report now works, and it is grouped by "companyname", but not grouped by account type. I have two types of account: Normal and Premium. One company has a type of account with us, and it draws on regular, not premium. What do you think is the problem.

I am new to crystal reporting. I am familiar with SQL though. The differences that I see

  • There is no aggregate function used for any column - SQL requires an aggregate field to produce meaningful results
  • The report contains about 10 fields, but the group is used only for two fields - in SQL you should group by all fields if there are more than two fields
  • The group of fields is in the middle and at the end - again in SQL it is important to arrange the groupby field

In this case, I first group the company name and then the account status. Any insight would be helpful.

Note that I generated an equivalent SQL statement from Crystal Report. This request has been approved, unless there were no group agents. I added those and the aggregate column myself, and I get the same result as in Crystal (but the SQL report is more accurate because it groups both fields not only one).

: . . , " " " ", .

+----+--------------+-------------+------+
| ID | Company Name | AccountType | Sale |
+----+--------------+-------------+------+
| 1  | ABC          | I           | 500  |
| 2  | ABC          | I           | 600  |
| 3  | ABC          | O           | 1000 |
| 4  | ABC          | O           | 2000 |
| 5  | ABC          | O           | 3000 |
| 6  | XYZ          | O           | 2500 |
| 7  | LMN          | O           | 3400 |
+----+--------------+-------------+------+

, ,

+--------------+-------------+------+
| Company Name | AccountType | Sale |
+--------------+-------------+------+
| ABC          | I           | 1100 |
| ABC          | O           | 6000 |
| XYZ          | O           | 2500 |
| LMN          | O           | 3400 |
+--------------+-------------+------+
0
1

:

:

1) SQL .

2) Crystal , , .

, , , , , .

, , , (, ).

(), Crystal โ„–1 "" " โ„–1" "".

, Crystal , , , , .

, . , .

, , .

, , , .

, .

, Crystal โ„–2 โ„–1 โ„–2 โ„– 1 .

, :

Group Header #1 (Company)
  Group Header #2 (Account Type)
    Details (the individual sale records)
  Group Footer #2
Group Header #1

. , , , โ„–2, โ„–2 .

, , , , , , โ„–2. (, , ) , .

+3

Source: https://habr.com/ru/post/1719760/


All Articles