pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
please give me select sqls examples to distinct these!
8+ messages / 3 participants
[nested] [flat]

* please give me select sqls examples to distinct these!
@ 2022-10-25 13:54  jacktby@gmail.com <jacktby@gmail.com>
  0 siblings, 1 reply; 8+ messages in thread

From: jacktby@gmail.com @ 2022-10-25 13:54 UTC (permalink / raw)
  To: pgsql-general <pgsql-general@lists.postgresql.org>


typedef enum SetOperation
{
    SETOP_NONE = 0,
    SETOP_UNION,
    SETOP_INTERSECT,
    SETOP_EXCEPT
} SetOperation;


jacktby@gmail.com


^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: please give me select sqls examples to distinct these!
@ 2022-10-25 14:06  Rob Sargent <robjsargent@gmail.com>
  parent: jacktby@gmail.com <jacktby@gmail.com>
  0 siblings, 2 replies; 8+ messages in thread

From: Rob Sargent @ 2022-10-25 14:06 UTC (permalink / raw)
  To: jacktby@gmail.com; +Cc: pgsql-general <pgsql-general@lists.postgresql.org>



> On Oct 25, 2022, at 7:55 AM, jacktby@gmail.com wrote:
> 
> 
> 
> typedef enum SetOperation
> {
>     SETOP_NONE = 0,
>     SETOP_UNION,
>     SETOP_INTERSECT,
>     SETOP_EXCEPT
> } SetOperation;
> jacktby@gmail.com

Please use just text. 
What ‘dialect’ are using? In Postgres
0: select * from table
1: select * from table union select * from table is same shape
2: select * from table join table b on Id = idb 
3: select * from table except select * from tableb

^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: Re: please give me select sqls examples to distinct these!
@ 2022-10-25 14:10  jacktby@gmail.com <jacktby@gmail.com>
  parent: Rob Sargent <robjsargent@gmail.com>
  1 sibling, 0 replies; 8+ messages in thread

From: jacktby@gmail.com @ 2022-10-25 14:10 UTC (permalink / raw)
  To: Rob Sargent <robjsargent@gmail.com>; +Cc: pgsql-general <pgsql-general@lists.postgresql.org>



> On Oct 25, 2022, at 7:55 AM, jacktby@gmail.com wrote:
> 
> 
> 
> typedef enum SetOperation
> {
>     SETOP_NONE = 0,
>     SETOP_UNION,
>     SETOP_INTERSECT,
>     SETOP_EXCEPT
> } SetOperation;
> jacktby@gmail.com

Please use just text. 
What ‘dialect’ are using? In Postgres
0: select * from table
1: select * from table union select * from table is same shape
2: select * from table join table b on Id = idb 
3: select * from table except select * from tableb



^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: please give me select sqls examples to distinct these!
@ 2022-10-25 15:22  David G. Johnston <david.g.johnston@gmail.com>
  parent: Rob Sargent <robjsargent@gmail.com>
  1 sibling, 1 reply; 8+ messages in thread

From: David G. Johnston @ 2022-10-25 15:22 UTC (permalink / raw)
  To: Rob Sargent <robjsargent@gmail.com>; +Cc: jacktby@gmail.com, pgsql-general <pgsql-general@lists.postgresql.org>

On Tue, Oct 25, 2022 at 7:06 AM Rob Sargent <robjsargent@gmail.com> wrote:

>
>
> On Oct 25, 2022, at 7:55 AM, jacktby@gmail.com wrote:
>
> 
>
> typedef enum SetOperation
> {
>     SETOP_NONE = 0,
>     SETOP_UNION,
>     SETOP_INTERSECT,
>     SETOP_EXCEPT
> } SetOperation;
> ------------------------------
> jacktby@gmail.com
>
>
> Please use just text.
> What ‘dialect’ are using? In Postgres
> 0: select * from table
> 1: select * from table union select * from table is same shape
> 2: select * from table join table b on Id = idb
> 3: select * from table except select * from tableb
>
>
#2 is probably conceptually correct but in this context should be written
as:

SELECT *
FROM table
INTERSECT
SELECT *
FROM table
Distinct is a default modifier, one can specify ALL if that isn't desired.

This is trivially answered by the documentation as well:

https://www.postgresql.org/docs/current/queries-union.html

David J.

^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: please give me select sqls examples to distinct these!
@ 2022-10-25 15:24  David G. Johnston <david.g.johnston@gmail.com>
  parent: David G. Johnston <david.g.johnston@gmail.com>
  0 siblings, 1 reply; 8+ messages in thread

From: David G. Johnston @ 2022-10-25 15:24 UTC (permalink / raw)
  To: Rob Sargent <robjsargent@gmail.com>; +Cc: jacktby@gmail.com, pgsql-general <pgsql-general@lists.postgresql.org>

On Tue, Oct 25, 2022 at 8:22 AM David G. Johnston <
david.g.johnston@gmail.com> wrote:

> On Tue, Oct 25, 2022 at 7:06 AM Rob Sargent <robjsargent@gmail.com> wrote:
>
>>
>>
>> 2: select * from table join table b on Id = idb
>>
>>
>>
> #2 is probably conceptually correct but in this context should be written
> as:
>
>
Actually, a join is NOT conceptually correct here - the output columns for
"SELECT *" will be wrong.

David J.

^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: please give me select sqls examples to distinct these!
@ 2022-10-25 15:56  Rob Sargent <robjsargent@gmail.com>
  parent: David G. Johnston <david.g.johnston@gmail.com>
  0 siblings, 1 reply; 8+ messages in thread

From: Rob Sargent @ 2022-10-25 15:56 UTC (permalink / raw)
  To: David G. Johnston <david.g.johnston@gmail.com>; +Cc: jacktby@gmail.com, pgsql-general <pgsql-general@lists.postgresql.org>

On 10/25/22 09:24, David G. Johnston wrote:
> On Tue, Oct 25, 2022 at 8:22 AM David G. Johnston 
> <david.g.johnston@gmail.com> wrote:
>
>     On Tue, Oct 25, 2022 at 7:06 AM Rob Sargent
>     <robjsargent@gmail.com> wrote:
>
>
>
>         2: select * from table join table b on Id = idb
>
>
>
>     #2 is probably conceptually correct but in this context should be
>     written as:
>
>
> Actually, a join is NOT conceptually correct here - the output columns 
> for "SELECT *" will be wrong.
>
> David J.
>
OK.  TBH I thought this was the JOOQ list! Didn't notice the typedef.  
So this is all about exact match "tables".

I suppose my #2 could be framed as
select a* from table as a join table as b on a.<criteria> = b.<criteria>
to be a functional equivalent of INTERSECT?

^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: please give me select sqls examples to distinct these!
@ 2022-10-25 15:58  David G. Johnston <david.g.johnston@gmail.com>
  parent: Rob Sargent <robjsargent@gmail.com>
  0 siblings, 1 reply; 8+ messages in thread

From: David G. Johnston @ 2022-10-25 15:58 UTC (permalink / raw)
  To: Rob Sargent <robjsargent@gmail.com>; +Cc: jacktby@gmail.com, pgsql-general <pgsql-general@lists.postgresql.org>

On Tue, Oct 25, 2022 at 8:56 AM Rob Sargent <robjsargent@gmail.com> wrote:

> On 10/25/22 09:24, David G. Johnston wrote:
>
> On Tue, Oct 25, 2022 at 8:22 AM David G. Johnston <
> david.g.johnston@gmail.com> wrote:
>
>> On Tue, Oct 25, 2022 at 7:06 AM Rob Sargent <robjsargent@gmail.com>
>> wrote:
>>
>>>
>>>
>>> 2: select * from table join table b on Id = idb
>>>
>>>
>>>
>> #2 is probably conceptually correct but in this context should be written
>> as:
>>
>>
> Actually, a join is NOT conceptually correct here - the output columns for
> "SELECT *" will be wrong.
>
> David J.
>
> OK.  TBH I thought this was the JOOQ list! Didn't notice the typedef.  So
> this is all about exact match "tables".
>
> I suppose my #2 could be framed as
>     select a* from table as a join table as b on a.<criteria> =
> b.<criteria>
> to be a functional equivalent of INTERSECT?
>

SELECT DISTINCT a.*

David J.

^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: please give me select sqls examples to distinct these!
@ 2022-10-25 18:10  Rob Sargent <robjsargent@gmail.com>
  parent: David G. Johnston <david.g.johnston@gmail.com>
  0 siblings, 0 replies; 8+ messages in thread

From: Rob Sargent @ 2022-10-25 18:10 UTC (permalink / raw)
  To: David G. Johnston <david.g.johnston@gmail.com>; +Cc: jacktby@gmail.com, pgsql-general <pgsql-general@lists.postgresql.org>

On 10/25/22 09:58, David G. Johnston wrote:
> On Tue, Oct 25, 2022 at 8:56 AM Rob Sargent <robjsargent@gmail.com> wrote:
>
>     On 10/25/22 09:24, David G. Johnston wrote:
>>     On Tue, Oct 25, 2022 at 8:22 AM David G. Johnston
>>     <david.g.johnston@gmail.com> wrote:
>>
>>         On Tue, Oct 25, 2022 at 7:06 AM Rob Sargent
>>         <robjsargent@gmail.com> wrote:
>>
>>
>>
>>             2: select * from table join table b on Id = idb
>>
>>
>>
>>         #2 is probably conceptually correct but in this context
>>         should be written as:
>>
>>
>>     Actually, a join is NOT conceptually correct here - the output
>>     columns for "SELECT *" will be wrong.
>>
>>     David J.
>>
>     OK.  TBH I thought this was the JOOQ list! Didn't notice the
>     typedef.  So this is all about exact match "tables".
>
>     I suppose my #2 could be framed as
>     select a* from table as a join table as b on a.<criteria> =
>     b.<criteria>
>     to be a functional equivalent of INTERSECT?
>
>
> SELECT DISTINCT a.*
>
> David J.
Yeah, sorry.  Meant to distinguish to two "table" defs in some way.

^ permalink  raw  reply  [nested|flat] 8+ messages in thread


end of thread, other threads:[~2022-10-25 18:10 UTC | newest]

Thread overview: 8+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2022-10-25 13:54 please give me select sqls examples to distinct these! jacktby@gmail.com <jacktby@gmail.com>
2022-10-25 14:06 ` Rob Sargent <robjsargent@gmail.com>
2022-10-25 14:10   ` jacktby@gmail.com <jacktby@gmail.com>
2022-10-25 15:22   ` David G. Johnston <david.g.johnston@gmail.com>
2022-10-25 15:24     ` David G. Johnston <david.g.johnston@gmail.com>
2022-10-25 15:56       ` Rob Sargent <robjsargent@gmail.com>
2022-10-25 15:58         ` David G. Johnston <david.g.johnston@gmail.com>
2022-10-25 18:10           ` Rob Sargent <robjsargent@gmail.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox