Skip site navigation (1) Skip section navigation (2)

Re: Sql result b where condition

From: Matthew Wakeling <matthew(at)flymine(dot)org>
To: "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Sql result b where condition
Date: 2010-01-25 12:10:34
Message-ID: alpine.DEB.2.00.1001251206470.6195@aragorn.flymine.org (view raw or flat)
Thread:
Lists: pgsql-performance
On Mon, 25 Jan 2010, A. Kretschmer wrote:
> In response to ramasubramanian :
>
> Please, create a new mail for a new topic and don't hijack other
> threads.

Even more so - this isn't probably the right mailing list for generic sql 
help questions.

>> select ENAME,ORIG_SALARY from employee where (ename='Tom' and
>> orig_salary=2413)or(orig_salary=1234 )
>>
>> if the fist condition(ename='Tom' and orig_salary=2413) is satified then 10
>> rows will be returned, for the second condition (orig_salary=1234 ) there
>> are 20 rows will be returned.
>> The order of display should be
>>
>> The first 10 rows then
>> next 20 rows.

> select ENAME,ORIG_SALARY, 1 as my_order from employee where (ename='Tom' and
> orig_salary=2413) union all select ENAME,ORIG_SALARY, 2 employee where
> (orig_salary=1234 ) order by my_order.

Or just:

select ENAME,ORIG_SALARY from employee where (ename='Tom' and
orig_salary=2413)or(orig_salary=1234 ) ORDER BY orig_salary DESC

as there is going to be only two values for orig_salary.

Matthew

-- 
 The early bird gets the worm. If you want something else for breakfast, get
 up later.

In response to

Responses

pgsql-performance by date

Next:From: A. KretschmerDate: 2010-01-25 12:24:00
Subject: Re: Sql result b where condition
Previous:From: Matthew WakelingDate: 2010-01-25 11:59:41
Subject: Re: Data Set Growth causing 26+hour runtime, on what we believe to be very simple SQL

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group