是否可以在不创建视图的情况下执行以下操作?即通过直接加入这些SELECT?
CREATE VIEW temp_first AS SELECT MIN(DATE) AS mindate,id FROM mytable GROUP BY id
#
SELECT *, t.mindate FROM aggregate_analysis a
JOIN temp_first t
ON t.id = a.id
WHERE (.... )
ORDER BY mindate DESC
答案 0 :(得分:4)
您应该能够使用子查询/子选择替换选择中的视图参考。
看看
像
这样的东西SELECT *,
t.mindate
FROM aggregate_analysis a JOIN
(
SELECT MIN(DATE) AS mindate,
id
FROM mytable
GROUP BY id
) as t ON t.id = a.id
WHERE (.... )
ORDER BY mindate DESC