Scenario 1_ Base Unit revenue re-imputation

Source: Internet
Author: User

Scene: The existing city January transfers revenue archive details, July basic unit adjustment, is required to collect the basic unit of January transfers income details.

An SQL statement equivalent to the VLOOKUP exact match feature in Excel, which corresponds to the record one by one required for each table, based on the key fields common to each table.

SQL Join Syntax Essentials:

① need to use multiple tables in the FROM clause when connecting;

② must use an ON clause when connecting, and write between from and where;

③ the columns in the SELECT clause when using a connection need to be written according to the < table's alias >.< column name > format;

④ connection INNER Join Select a record that matches key fields in two tables;

⑤ left JOIN selects all records in the first table and records in the second table that match the key fields;

⑥ Right-connect to select All records for the second table weight and the first table-critical field to match.

--View "Revenue summary Details _ new"

CREATE VIEW Revenue Summary Details _ New (phone number, transfers month, transfers amount, channel code, channel name, new base unit)

SELECT Revenue summary details. Phone number

, Revenue summary details. Transfers Month

, Revenue summary details. Transfers Amount

, revenue summary details. Channel Coding

, revenue summary details. Channel Name

, income collection. New base Unit

from Revenue summary detail left JOIN revenue imputation

on revenue summary details. CHANNEL encoding = revenue collection. Channel coding

--screening base unit A for transfers customers

SELECT *

from Revenue summary details _ NEW

WHERE new base unit in (' base unit a ')

Reference: http://www.w3school.com.cn/sql/sql_join.asp

Scenario 1_ Base Unit revenue re-imputation

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.