1
是否有可能重寫以下視圖,以便用戶有可能使用WHERE子句(WHERE overlap> @param,參見下面的註釋)參數化視圖?它有可能嗎? where子句應該在group by子句之前影響。如何在SqLite視圖語句中放置where條件?
我嘗試從表'vl'中選擇並匹配行(外部聯接)與來自語句的行,該語句在另一個表('vlda')中計數。
THX
CREATE VIEW dr AS SELECT vl.unique_object_id AS unique_object_id, ifnull(vlda.detectioncount, 0) AS detectioncount, vl.count AS labelcount, (1.0*ifnull(vlda.detectioncount, 0)/vl.count) AS detectionrate, vlda.evalround_id FROM viewlabelcount vl LEFT OUTER JOIN ( SELECT count() as detectioncount, unique_object_id, evalround_id FROM viewlabeldetections_best -- WHERE overlap > 0.5 -- is it possible to parametrize? GROUP BY unique_object_id ) AS vlda ON vl.unique_object_id = vlda.unique_object_id
Thx。同時,我還發現了另一種「模擬」複雜語句的選項:將語句作爲文本放入特殊表中,然後從表中讀取語句並從應用程序中執行語句,包括必要的語句參數:http:// stackoverflow。 com/questions/3402841/does-sqlite-support-store-procedures。 – dousin