Re: RE: Re(2): optimize sql

From: pgsql-sql(at)fc(dot)emc(dot)com(dot)ph (pgsql-sql)
To: HLafleur(at)phoenixforge(dot)com, pgsql-sql(at)postgresql(dot)org
Subject: Re: RE: Re(2): optimize sql
Date: 2000-07-28 02:27:39
Message-ID: fc.000f5672005a3569000f5672005a3569.5a35b7@fc.emc.com.ph
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

but active is a boolean field.

HLafleur(at)phoenixforge(dot)com writes:
>If you know that 't' will always be the highest character in the active
>field for all records:
>
>SELECT name FROM office, office_application
>WHERE code = office_code
>GROUP BY name
>HAVING MAX(active) < 't'
>
>Of course, if you have an active that is 'z' for example, then this won't
>work. I think this should work also regardless of max(active) for the
>table:
>
>SELECT name FROM office, office_application
>WHERE code = office_code AND active <= 't'
>GROUP BY name
>HAVING MAX(active) < 't'
>UNION
>SELECT name FROM office, office_application
>WHERE code = office_code AND active >= 't'
>GROUP BY name
>HAVING MIN(active) > 't'
>
>Henry
>
>
>-----Original Message-----
>From: pgsql-sql(at)fc(dot)emc(dot)com(dot)ph [mailto:pgsql-sql(at)fc(dot)emc(dot)com(dot)ph]
>Sent: Wednesday, July 26, 2000 9:40 PM
>To: pgsql-sql(at)postgresql(dot)org; reedstrm(at)rice(dot)edu
>Subject: Re(2): [SQL] optimize sql
>
>
>reedstrm(at)rice(dot)edu writes:
>>How does the output of the above differ from:
>>
>>SELECT name FROM office, office_application
>>WHERE code = office_code
>>AND active != 't';
>>
>>Without knowing the table structures (which tables to active, code,
>>and office_code belong to?) it's hard to suggest much else.
>>
>>Ross
>
>
>The name and code fields belong to office table. While
>office_code and active fields belong to office_application table.
>The name field have duplicates and among the duplicates,
>only one active field is TRUE. I just wanted to get name field
>that has no TRUE active field. Any other idea? Thanks.
>
>sherwin

Browse pgsql-sql by date

  From Date Subject
Next Message Carolyn Lu Wong 2000-07-28 08:21:02 Transactions
Previous Message Bernie Huang 2000-07-27 22:19:35 BLOBs