table of Contents
Foreword
This article is based on the classic examples of books I read SQL written notes, I think the only record valuable content
Chapter One: retrieve records
Where the use of aliases in the words
--错误实例
select p as PartNumber from Product where PartNumber='LMKHS'
Where the use of aliases in words, the result of an error, the reason is because SQL execution order is
- From
- Where
- Select
Where you can see the first implementation than Select, Select inside so the alias is defined, Where there certainly does not take
Solution
If you want to use the following in Where in, you can use the embedded view
- Aggregation function: for example, min (), max (), sum (), avg ()
- Scalar query: must and can only return the results of a query select one row
- Window function
- Alias: this embodiment as
--内嵌视图如下
select * from(
select p as PartNumber from Product
) temp where PartNumber='LMKHS'