Обсуждение: please give me select sqls examples to distinct these!

Поиск
Список
Период
Сортировка

please give me select sqls examples to distinct these!

От
"jacktby@gmail.com"
Дата:

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

jacktby@gmail.com

Re: please give me select sqls examples to distinct these!

От
Rob Sargent
Дата:


On Oct 25, 2022, at 7:55 AM, jacktby@gmail.com wrote:

body { line-height: 1.5; } body { font-size: 14px; font-family: "Microsoft YaHei UI"; color: rgb(0, 0, 0); line-height: 1.5; }

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

Re: Re: please give me select sqls examples to distinct these!

От
"jacktby@gmail.com"
Дата:
thanks
 

jacktby@gmail.com
 
Date: 2022-10-25 22:06
To: jacktby
Subject: Re: please give me select sqls examples to distinct these!
div.FoxDIV_20221025220947792 { font-size: 10.5pt } div.FoxDIV_20221025220947792 { line-height: 1.5; } div.FoxDIV_20221025220947792 { font-size: 14px; font-family: "Microsoft YaHei UI"; color: rgb(0, 0, 0); line-height: 1.5; }


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

Re: please give me select sqls examples to distinct these!

От
"David G. Johnston"
Дата:
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;


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:


David J.

Re: please give me select sqls examples to distinct these!

От
"David G. Johnston"
Дата:
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.

Re: please give me select sqls examples to distinct these!

От
Rob Sargent
Дата:
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?

Re: please give me select sqls examples to distinct these!

От
"David G. Johnston"
Дата:
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.

Re: please give me select sqls examples to distinct these!

От
Rob Sargent
Дата:
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.