当前位置:网站首页>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 .
边栏推荐
- I brush the question I - copy the linked list with random pointer
- [micro service sentinel] real time monitoring | RT | throughput | concurrency | QPS
- Custom control - round dot progress bar (imitating one key acceleration in security guard)
- bindservice方法实现音乐播放暂停
- 汇编语言(4)函数传参
- Text editor for QT project practice - Episode 10
- [practical series] full WiFi coverage at home
- 2022年起重机司机(限桥式起重机)考试题库模拟考试平台操作
- 扎克伯格上手演示四款VR头显原型机,Meta透露元宇宙「家底」
- Scala trait inheritance class
猜你喜欢

利用 Redis 的 sorted set 做每周热评的功能
![[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

51单片机多机通信
![[micro service sentinel] real time monitoring | RT | throughput | concurrency | QPS](/img/fc/6b36759570b9b1007d2640009576d9.png)
[micro service sentinel] real time monitoring | RT | throughput | concurrency | QPS

Cobalt Strike安装教程

Library management system code source code (php+css+js+mysql) complete code source code
![[redis realizes seckill service ②] solution to oversold problem](/img/b6/3073def06a56565894c28e49767e3e.png)
[redis realizes seckill service ②] solution to oversold problem

Cobalt strike installation tutorial

Text editor of QT project practice ---------- episode 11

扎克伯格上手演示四款VR头显原型机,Meta透露元宇宙「家底」
随机推荐
腾讯云WeCity丨你好 2022!
I brush the question I - copy the linked list with random pointer
Text editor of QT project practice ---------- episode 11
2022R1快开门式压力容器操作考题及答案
What to learn in VB [easy to understand]
腾讯搬家了!
The interview questions and answers for the high-frequency software test of Dachang help you prepare for the golden nine silver ten
2022r1 quick opening pressure vessel operation test questions and answers
Scala responsibility chain pattern
[practical series] full WiFi coverage at home
最新QQ微信域名防红PHP程序源码+强制跳转打开
Cobalt Strike安装教程
How about compass stock trading software? Is it safe?
Mobile security tool -dex2jar
Mysql database Chapter 1 Summary
A plug-in framework for implementing registration free and login verification with hook technology
利用 Redis 的 sorted set 做每周热评的功能
Zuckerberg demonstrated four VR head display prototypes, and meta revealed the "family" of metauniverse
Rich text tables, lists, pictures
[redis realizes seckill service ②] solution to oversold problem