对未出现在记录集中的字段选择 DISTINCT?

发布于 2024-09-01 01:57:25 字数 87 浏览 12 评论 0原文

我想做一个SELECT DISTINCT guid, ...,但我不希望guid出现在记录集中。我该怎么做?

I want to do a SELECT DISTINCT guid, ..., but I don't want guid appearing in the recordset. How do I do this?

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

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

发布评论

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

评论(4

随波逐流 2024-09-08 01:57:25
SELECT a.Field2
     , a.Field3
  FROM (SELECT DISTINCT a.guid
                      , a.Field2
                      , a.Field3
                   FROM table1 a)  a
SELECT a.Field2
     , a.Field3
  FROM (SELECT DISTINCT a.guid
                      , a.Field2
                      , a.Field3
                   FROM table1 a)  a
那支青花 2024-09-08 01:57:25

您也可以这样做。

SELECT x, y FROM tbl GROUP BY guid, x, y

这里的缺点是您必须重复 GROUP BY 子句中的列列表,这很烦人,但其他答案也是如此。

You can also do

SELECT x, y FROM tbl GROUP BY guid, x, y

The drawback here is that you have to duplicate the column list in the GROUP BY clause, which is annoying, but the other answers do as well.

流殇 2024-09-08 01:57:25

将其包裹在子选择中?

select my, interesting, columns
from (
    select distinct GUID, ...
    from ...
)

Wrap it in a subselect?

select my, interesting, columns
from (
    select distinct GUID, ...
    from ...
)
等风来 2024-09-08 01:57:25

首先将不同的值选择到临时表中。

然后仅选择您想要的值。

select the distinct values into a temp table first.

Then select out only the values you want.

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