Advice: Based on my current situation, how can I easily obtain the financial report?

Source: Internet
Author: User
Advice: Based on my current situation, how can I easily obtain the financial report? Delphi/Windows SDK/API
Http://www.delphi2007.net/DelphiDB/html/delphi_20061219223120214.html
I put all the secondary subjects in a table (sub_list)
Field:
Sub_id (level 2 subject 'category ID ),
Sub_name (second-level account name ),
Acc_id (parent account ID ),
Acc_name (parent account name ),
Debit (borrow amount ),
Lender (loan amount ).
Each subject has multiple records

How to generate the following report:
Upper-level account 1 borrow amount, total loan amount,
Level 2 account 1 borrow amount, total loan amount,
Level 2 account 2 borrow amount, total loan amount
.....
Upper-level account 2 borrow amount, total loan amount,
Level 2 account 1 borrow amount, total loan amount,
Level 2 account 2 borrow amount, total loan amount

Lao Feng is here to help. Occupy 80 points

select acc_id, acc_name name, sum (debit) sum_debit, sum (lender) sum_lender from sub_list group by acc_id, acc_name
Union
select acc_id, sub_name name, sum (debit) sum_debit, sum (lender) sum_lender from sub_list group by acc_id, sub_name
order by acc_id, name

Select acc_id, acc_name name, k = 1, sum (debit) sum_debit, sum (lender) sum_lender from sub_list group by acc_id, acc_name

Union

Select acc_id, sub_name name, K = 2, sum (debit) sum_debit, sum (lender) sum_lender from sub_list group by acc_id, sub_name

Order by acc_id, K, name

What is K? Sort?
In my opinion, there are two queries. You cannot implement the results of the preceding report. It is easy to use RM.

You cannot implement the results of the preceding report.

----------------------------
Practice is the only criterion for testing truth.

Thank you, Feng! I 've been in the computer for the past few days, wikin, TMD! Reinstall the system. Try again after installation!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.