Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Oracle with as usage

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

The With query statement begins with with, which is equivalent to building a temporary table before the query, and the specified query results are stored in the temporary table, and then it can be used many times for further analysis and processing.

Syntax:

With _ tempTable as (select * from table) select * from _ tempTable

Example:

With _ tempStudent as (select * from t_student t where class = 'Class 3, Grade 8') select sex,count (1) nums from _ tempStudent where sex = 'male' and height > '170'union allselect sex,count (1) nums from _ tempStudent where sex =' female 'and height >' 160'

Multiple with as uses each temporary stock is directly separated by ","

With T1 as (select * from student where name in ('Zhang San','Li Si'), T2 as (select * from student where name in ('Wang Wu') select * from t1union select * from T2

If the with as is nested and there are multiple with as, the temporary object declared first can be called directly within the following as.

With T1 as (select * from student where name in ('Zhang San','Li Si'), T2 as (select * from T1 where name in ('Wang Wu')) select * from T2

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report