High-score reward-solving ideas

Source: Internet
Author: User
High score Reward
Financial statements:

Serial User name Renewal (yuan) free (yuan) margin (yuan) registration fee (yuan) IP address fee (yuan) usage fee (yuan)

0 Wsz Xiaobai 60 10 0 0 50 20

1 BBB zhangs 50 0 0 0 30 100


Table a the following fields:

User (login name)
Name (name)

-----------------------------

Table B has the following 3 fields:

Type: (5 types: renewal, gift, margin, registration fee, IP address fee, depending on the case type value is different)

Savingnum (Renewal)

User (login name)

Time

----------------------------
Table C has the following fields:


User (login name)

Charge1 (User fee)

Time

----------------------------

Table D has the following fields:


User (login name)

Charge2 (User fee)
Time

Association: The user of the four tables is equal and unique in each table.
Note: Is the report, isolated value, is a range of a field ' and '
The usage fee in each record is 0 if the value in the D table is not NULL, and if the value in table C is not 0, then there is no D table.

Problem:

1 Queries: Find a range of renewals ($star _savingnum<=savingnum<= $end _savingnum) within a conditional time ($star _time<=time<= $end _time)

2 queries: Find a range of usage fees ($star _savingnum<=savingnum<= $end _savingnum) within a conditional time ($star _time<=time<= $end _time)






------Solution--------------------
What depends on your needs?
1 Table B Type: (5 types: renewal, gift, margin, registration fee, IP address fee), type of structure, the statistical itself has an impact.

Either take a certain type of renewal for all users to do the statistics, or take all the types of individual users to do statistics, which can be achieved through group by.

The 2 C and D table structures are basically the same and do not know what you call (if the value in the D table is not NULL, then it is 0 in the C table, and if the value in the C table is not 0, there is no solution in the D table).
If a user has a value in the C table and has a value in the D table, the difficulty is artificially increased.


------Solution--------------------
Explore
What depends on your needs?
1 Table B Type: (5 types: renewal, gift, margin, registration fee, IP address fee), type of structure, the statistical itself has an impact.

Either take a certain type of renewal for all users to do the statistics, or take all the types of individual users to do statistics, which can be achieved through group by.

The 2 C and D table structures are basically the same and do not know what you call (if the value in the D table is not NULL, then it is 0 in the C table, and if the value in the C table is not 0, there is no solution in the D table).
If a user has a value in the C table and has a value in the D table, the difficulty is artificially increased.



------Solution--------------------
discuss
The charge value of a record, which exists in the C table (not 0), does not exist in the D table.

As long as the D table exists, it will not exist in the C table, (0 None)
  • 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.