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

Alias
Alias, Alias means . stay SQL Server In the database of , We can use AS Specify aliases for tables or columns or queries .
Please don't ignore this ,AS It's especially useful at times , It can be said that the frequency of use is very high .
Basic grammar
Table grammar 1:
SELECT Column name (*) FROM surface AS Alias
Column syntax 1:
SELECT Column name AS Alias FROM surface
Using examples
Case data :


In the database of white tea machine , There is a name “TEST” The database of , There is a name “ Product list ” The dimension table and the name are “ Sales details ” The fact sheet of .
Example 1:
stay PowerBI in , take “ Product list ” Medium [ Name of commodity ] Name it “Product”.
SELECT [ Name of commodity ] AS Product FROM [ Product list ]

give the result as follows :

Example 2:
stay PowerBI in , take “ Sales details ” Name it “Fact_Detail”, Again from “Fact_Detail” Table acquisition [ sales volumes ] Aggregate value of .

give the result as follows :


AS In the first two examples, it does not reflect its value , We can look at it from the perspective of the result set .
notes : Result set refers to the result set after query .
Example 3:
stay PowerBI in , quote [ Product list ] All the information about , And calculate according to the correlation [ Name of commodity ] Corresponding [ Sales details ] In the table [ sales volumes ] Summary .
SELECT [ Product list ].* , SUM([ Sales details ].[ sales volumes ]) AS Quantity
FROM [ Product list ]
LEFT JOIN [ Sales details ]
ON [ Product list ].[ Name of commodity ]=[ Sales details ].[ Name of commodity ]
GROUP BY [ Product list ].[ Name of commodity ],[ Product list ].[ Item number ],[ Product list ].[ Classification of goods ],[ Product list ].[ The sale price ],[ Product list ].[ cost ]
ORDER BY Quantity DESC

give the result as follows :

Of course , We can also use the following expression .
SELECT [ Product list ].*, SUMARRIZE.Quantity
FROM [ Product list ]
LEFT JOIN
(SELECT [ Sales details ].[ Name of commodity ] ,
SUM([ Sales details ].[ sales volumes ]) AS Quantity
FROM [ Sales details ]
GROUP BY [ Sales details ].[ Name of commodity ]) AS SUMARRIZE
ON [ Product list ].[ Name of commodity ]=SUMARRIZE.[ Name of commodity ]
ORDER BY Quantity DESC

give the result as follows :



This is white tea , One PowerBI Beginners .
边栏推荐
- Scala adapter pattern
- QT (35) - operate excel qxlsx qaxobject
- Programmer: did you spend all your savings to buy a house in Shenzhen? Or return to Changsha to live a "surplus" life?
- Deploy a production cluster using Loki microservice pattern
- Convolution and transpose convolution
- JSON file of China's provincial boundaries
- A small crawler program written by beginners
- How much commission does CICC wealth securities open an account? Is stock account opening and trading safe and reliable?
- adb shell getevent
- 卷积与反卷积关系超详细说明及推导(反卷积又称转置卷积、分数步长卷积)
猜你喜欢

使用 Loki 微服务模式部署生产集群

Heavyweight: the domestic ide was released, developed by Alibaba, and is completely open source! (high performance + high customization)

2022年起重机司机(限桥式起重机)考试题库模拟考试平台操作

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

Thermodynamic diagram display correlation matrix

The interview questions and answers for the high-frequency software test of Dachang help you prepare for the golden nine silver ten

Zuckerberg demonstrated four VR head display prototypes, and meta revealed the "family" of metauniverse

2022r1 quick opening pressure vessel operation test questions and answers
![[microservices sentinel] cluster link | microservices cluster environment construction](/img/75/3cc6abf1e72d651b082415db9db46c.png)
[microservices sentinel] cluster link | microservices cluster environment construction

If the order has not been paid for 30 minutes, it will be automatically cancelled. How can I achieve this?
随机推荐
Bi-sql delete
启动服务11111
QT electronic clock
重磅:国产IDE发布,由阿里研发,完全开源!(高性能+高定制性)
生态护航 云服务商挥起“英特尔大旗”
Programmer: did you spend all your savings to buy a house in Shenzhen? Or return to Changsha to live a "surplus" life?
Scala adapter pattern
腾讯完成全面上云 打造国内最大云原生实践
移动安全工具-jar
移动安全工具-dex2jar
Scala trait construction mechanism
Golang示例续期锁:Redis+Channel+sync.Mutex
Sanic service startup failed
How to store dataframe data in pandas into MySQL
Mobile security tool jarsigner
腾讯搬家了!
[redis realizes seckill business ③] specific implementation of optimistic lock for oversold problem
中金财富证券开户佣金多少呢?股票开户交易安全靠谱吗?
4 years of working experience, and you can't tell the five communication modes between multithreads. Can you believe it?
EVM简略