子查詢分解
引自Johnathion的COB Fundamental:
數學家的對話:
“三個女兒年齡和36,年齡和是在場所有人的總數,大女兒又只寵物倉鼠”
with age_list as(
select rownum age from dba_objects where rownum <=36),
product_check as(
select age1.age youngest,
age2.age middle,
age3.age oldest,
age1.age + age2.age + age3.age as summed,
age1.age * age2.age * age3.age as product
from age_list age1
,age_list age2
,age_list age3
where age2.age >= age1.age
and age3.age >= age2.age
and age1.age * age2.age * age3.age =36)
,
summed_check as (
select youngest, middle, oldest, summed, product
from
( select youngest, middle, oldest, summed, product, count(*) over(partition by summed) ct
from product_check)
where ct > 1)
select * from summed_check
where oldest > middle
;
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/661919/viewspace-1004338/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- SQL Server 查詢分解SQLServer
- 子查詢-表子查詢
- 複雜查詢—子查詢
- 一條SQL語句查詢塊分解及查詢轉換SQL
- SQL查詢的:子查詢和多表查詢SQL
- 相關子查詢&非相關子查詢概念
- MySQL子查詢MySql
- 子串查詢
- 使用子查詢
- MYsql 子查詢MySql
- oracle子查詢Oracle
- 查詢子串
- 11子查詢
- sql子查詢SQL
- informix子查詢ORM
- MySQL聯結查詢和子查詢MySql
- select查詢之三:子查詢
- mysql-分組查詢-子查詢-連線查詢-組合查詢MySql
- 區分關聯子查詢和非關聯子查詢
- sql語法相關子查詢與非相關子查詢SQL
- exist-in和關聯子查詢-非關聯子查詢
- MySQL之連線查詢和子查詢MySql
- 巢狀子查詢巢狀
- GORM subquery 子查詢GoORM
- SQL--子查詢SQL
- Oracle with重用子查詢Oracle
- oracle with 子查詢用法Oracle
- select子查詢
- mysql的子查詢MySql
- Javaweb-子查詢JavaWeb
- MYSQL學習筆記25: 多表查詢(子查詢)[標量子查詢,列子查詢]MySql筆記
- Oracle查詢轉換(五)子查詢展開Oracle
- 關聯查詢子查詢效率簡單比照
- 【MySQL】檢視&子查詢MySql
- MySQL 相關子查詢MySql
- 教你使用SQLite 子查詢SQLite
- [MYSQL -14]使用子查詢MySql
- 【MySQL】子查詢之一MySql