我可以不使用视图直接连接 SELECT 语句吗?

发布于 2024-10-02 13:15:12 字数 271 浏览 3 评论 0原文

是否可以在不创建视图的情况下执行以下操作?即直接加入这些 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

Is it possible to do the following without a creating a view in between? I.e. by just joining these SELECTs directly?

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

忆梦 2024-10-09 13:15:12

您应该能够用子查询/子选择替换选择中的视图引用。

查看

类似的东西

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

You should be able to replace the view refernce in the select with a sub query/sub select.

Have a look at

Something like

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文