Query Related to Check Individual Values of Range!!!

Поиск
Список
Период
Сортировка
От Jay Kumar Yadav
Тема Query Related to Check Individual Values of Range!!!
Дата
Msg-id 20060526140508.8154.qmail@webmail64.rediffmail.com
обсуждение исходный текст
Ответы Re: Query Related to Check Individual Values of Range!!!  (Kris Jurka <books@ejurka.com>)
Список pgsql-jdbc

Dear Friends/Sirs/Madams;

I would like to know about the query or function that can check each value between a range. By Use of Between if either value match, row is retrieved, i want to know is it possible to check all values of Between  must be for particular field.

Any Idea/Suggetion/Comment would be appriciated and welcome.

Let me clear the Scenario;

In short;
Using Required Field table is as  follows;

Table 'DIMENSIONS'

CREATE TABLE DIMENSIONS (
SNO SERIAL PRIMARY KEY,
ID  NUMERIC,
YEAR NUMERIC);

INSERT INTO DIMENSIONS (ID, YEAR) VALUES (1,2005);
INSERT INTO DIMENSIONS (ID, YEAR) VALUES (1,2006);
INSERT INTO DIMENSIONS (ID, YEAR) VALUES (1,2007);

INSERT INTO DIMENSIONS (ID, YEAR) VALUES (2,2004);
INSERT INTO DIMENSIONS (ID, YEAR) VALUES (2,2005);
INSERT INTO DIMENSIONS (ID, YEAR) VALUES (2,2006);

INSERT INTO DIMENSIONS (ID, YEAR) VALUES (3,2005);
INSERT INTO DIMENSIONS (ID, YEAR) VALUES (3,2006);
INSERT INTO DIMENSIONS (ID, YEAR) VALUES (3,2007);

SELECT * from DIMENSIONS;
As follows :

SNO | ID | YEAR
----------------
  1 |  1 | 2005
  2 |  1 | 2006
  3 |  1 | 2007
  4 |  2 | 2004
  5 |  2 | 2005
  6 |  2 | 2006
  6 |  3 | 2005
  7 |  3 | 2006
  8 |  3 | 2007
-----------------

I require the Query to Retrieve the 'ID' which Possess year between 2004 and 2006!
So for ID must have each year 2004, 2005, 2006.

If i use query with or without group on ID with Having or Where 'BETWEEN year 2004 and 2006' then ID 1,2 and 3 are listed but what i need is ID must have records for all 2004, 2005 and 2006 so Only ID=2  should retrieve.

SELECT ID FROM DIMENSIONS GROUP BY ID,YEAR HAVING YEAR BETWEEN 2004 and 2006;

It returns all 1,2,3 IDs.
I need ID having all values of 2004-2006 ( 2004,2005,2006) should be return means ID=2 here.

So for Front End can be used but i am trying to Utilize the DB if possible.

Thanks in Advance!!

Best Regard and Wishes.
    -  Jay kumar yadav.
       9893123415.

В списке pgsql-jdbc по дате отправления:

Предыдущее
От: Dave Cramer
Дата:
Сообщение: Re: postgresql 8.1.4
Следующее
От: "Oscar Ortiz"
Дата:
Сообщение: Migrar una base de datos access a postgres