Re: Complex SELECT Statement help needed

From: Raymond O'Donnell <rod(at)iol(dot)ie>
To: flashbangpop <daniel(dot)oostra(at)ssaihq(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Complex SELECT Statement help needed
Date: 2010-02-22 18:25:07
Message-ID: 4B82CC03.2020509@iol.ie
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 22/02/2010 18:14, flashbangpop wrote:

> I'm new to postgres and am trying to display rows in a table that are have a
> value between 2 fields.
>
> The rows I want to display should be selected by the grademin or grademax
> fields. I'd like to display the rows in sections that are labeled Grades
> 3-5, 6-8, and 9-12.
>
> The problem that I am having is I can't figure out how to write a statement
> that will check both fields. And, especially when I have values in the like
> this:
>
> grademin 4 grademax 12 that I want to show up in all levels
> grademin 5 grademax 12 ""
> grademin 6 grademax 9 in 6-9 and 9-12
>
> Below is what I have so far, but it falls flat on it's face when trying to
> display rows that don't fall between the specific range.
>
> How can I check grademin and max in the same statement?

Are grademin and grademax two separate columns in the table? If so,
simply imcude as many conditions as you need:

select ....
where grademin ...
and grademax ....
and ....

Ray.

--
Raymond O'Donnell :: Galway :: Ireland
rod(at)iol(dot)ie

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Richard Broersma 2010-02-22 18:30:00 Re: Sorting performance vs. MySQL
Previous Message Frank Heikens 2010-02-22 18:17:55 Re: Sorting performance vs. MySQL