当前位置:网站首页>Bi-sql - different join
Bi-sql - different join
2022-06-25 01:12:00 【Powerbi white tea】

Different JOIN
White tea has been described before JOIN Some basic usage of , But actually JOIN There are several types of variants .
Different JOIN, The result returned is also different .

JOIN There are several types of :
JOIN, If there is at least one match in the table , Then go back to the line ;
LEFT JOIN, Even if there is no match in the right table , Also return all rows from the left table ;
RIGHT JOIN, Even if there is no match in the left table , Also returns all rows from the right table ;
FULL JOIN, As long as there is a match in one of the tables , Just go back .
Basic grammar
grammar :
SELECT Column name (*) FROM surface 1 name (JoinType) JOIN surface 2 name ON surface 1 name .[ Column fields ] = surface 2 name .[ Column fields ]
Be careful
INNER It can be omitted by default ,JOIN Equate to INNER JOIN.
Using examples
Case data :


In the database of white tea machine , There is a name “TEST” The database of , There is a name “Customer” The dimension table and the name are “Fact” The fact sheet of , Two tables go through IDKEY relation .
Example 1:
JOIN usage . stay PowerBI Use in JOIN take Customer Table and Fact Table for association query .
SELECT Customer.[NAME],Fact.[AMOUNT] FROM Customer JOIN Fact ON Customer.[IDKEY]=Fact.[IDKEY]

give the result as follows :

The result returned at this point , Whether it's Customer Watch or Fact No matching items in the table will appear .
Example 2:
LEFT JOIN usage . stay PowerBI Use in LEFT JOIN take Customer Table and Fact Table for association query .
SELECT Customer.[NAME],Fact.[AMOUNT] FROM Customer LEFT JOIN Fact ON Customer.[IDKEY]=Fact.[IDKEY]

give the result as follows :

The result returned at this point , Take the left table Customer Table based , Whether the matching item is in Fact Is there... In the table , All items in the left table will be rendered .
Example 3:
RIGHT JOIN usage . stay PowerBI Use in RIGHT JOIN take Customer Table and Fact Table for association query .
SELECT Customer.[NAME],Fact.[AMOUNT] FROM Customer RIGHT JOIN Fact ON Customer.[IDKEY]=Fact.[IDKEY]

give the result as follows :

The result returned at this point , To the right Fact Table based , Whether the matching item is in Customer Is there... In the table , All items in the right table will be rendered .
Example 4:
FULL JOIN usage . stay PowerBI Use in FULL JOIN take Customer Table and Fact Table for association query .
SELECT Customer.[NAME],Fact.[AMOUNT] FROM Customer FULL JOIN Fact ON Customer.[IDKEY]=Fact.[IDKEY]

give the result as follows :

The result returned at this point , Mainly double tables , Whether the corresponding item exists in other tables or not , Will present .
JOIN Different types of , The result returned is also different , The specific usage depends on our actual application scenarios and business logic , Start according to your needs .


This is white tea , One PowerBI Beginners .
边栏推荐
猜你喜欢

QT electronic clock

QT (35) - operate excel qxlsx qaxobject

2022R1快开门式压力容器操作考题及答案

移动安全工具-jar
最新QQ微信域名防红PHP程序源码+强制跳转打开

4年工作经验,多线程间的5种通信方式都说不出来,你敢信?
![[redis realizes seckill business ③] specific implementation of optimistic lock for oversold problem](/img/01/5ec4e5dae1748dce3d5dee33a24b0b.png)
[redis realizes seckill business ③] specific implementation of optimistic lock for oversold problem

Examination questions and mock examination for safety management personnel of hazardous chemical business units in 2022

丹麦技术大学首创将量子计算应用于能源系统潮流建模

2022年全国最新消防设施操作员(高级消防设施操作员)模拟题及答案
随机推荐
[micro service sentinel] real time monitoring | RT | throughput | concurrency | QPS
我想问一下兴业证券怎么开户?通过链接办理股票开户安全吗
2022年危险化学品经营单位安全管理人员考试试题及模拟考试
Distinguish between i++ and ++i seconds
Thermodynamic diagram display correlation matrix
网上开户选哪个证券公司?网上开户安全么?
Scala trait construction mechanism
最新QQ微信域名防红PHP程序源码+强制跳转打开
2022熔化焊接与热切割复训题库模拟考试平台操作
腾讯完成全面上云 打造国内最大云原生实践
欢迎来到联想智能大屏的新世界
Text editor for QT project practice - Episode 10
QT electronic clock
Start service 11111
扎克伯格上手演示四款VR头显原型机,Meta透露元宇宙「家底」
adb shell getevent
Redis + Lua implementation of distributed interface current limiting
[microservices sentinel] cluster link | microservices cluster environment construction
这个国庆!腾讯云WeCity陪您一同出行,点亮城市地标...
A website for programmers with a monthly salary of 30K