1
我有很複雜的查詢,我想創建一個視圖。查詢如下:從複雜的選擇創建視圖
select s.avg as c3, fs.bayes, fs.sure, fs.visu, fs.fstd from
(
SELECT AVG(q.c3), COUNT(q.c3), q.std
FROM (
SELECT std, c3, ROW_NUMBER() OVER (PARTITION BY std ORDER BY id) AS rn
FROM ssims
WHERE obraz = 'peppers2' and noisetype ='L' and data>'2009-12-23' and maska = 9
) q
WHERE rn <= 15
GROUP BY
std
) s
,(
SELECT AVG(f.bayes) as bayes, AVG(f.sure) as sure, AVG(f.visu) as visu, COUNT(f.bayes) as fcount, f.std as fstd
FROM (
SELECT std, bayes, sure, visu, ROW_NUMBER() OVER (PARTITION BY std ORDER BY id) AS rn
FROM falki_ssim
WHERE obraz = 'peppers2' and noisetype ='L'
) f
WHERE rn <= 15
GROUP BY
std
) fs
where s.std = fs.fstd
它選擇我用指定參數測試的平均結果。此查詢的輸出返回10行(標準值從5到50與步驟5,所以5,10,15 ...)和5列:c3,bayes,當然,可視,std
但我想以便能夠更改兩個子查詢的obraz
和noisetype
字段。因此,在創建這樣的說法後,我希望能夠以這種方式選擇的結果:
select * from my_view where obraz='peppers2' and noisetype = 'L'
怎麼辦呢?
首先,obraz和noisetype必須出現在選擇的每個級別。實際上有三種選擇。即使糾正後,查詢不幸運行,因爲我期望(它只選擇obraz/noisetype的所有可用 – Gacek 2010-01-09 14:01:02
我發現一個錯誤的組合:row_number中的分區還需要包括obraz和noisetype。是固定在兩個地方 – 2010-01-09 14:11:17
是的,現在它完美的工作,謝謝! – Gacek 2010-01-09 15:00:19