Lists: | pgsql-jdbc |
---|
From: | "Jay Kumar Yadav" <jaykumaryadav1980(at)rediffmail(dot)com> |
---|---|
To: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | Query Related to Check Individual Values of Range!!! |
Date: | 2006-05-26 14:05:08 |
Message-ID: | 20060526140508.8154.qmail@webmail64.rediffmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | 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.
From: | Kris Jurka <books(at)ejurka(dot)com> |
---|---|
To: | Jay Kumar Yadav <jaykumaryadav1980(at)rediffmail(dot)com> |
Cc: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | Re: Query Related to Check Individual Values of Range!!! |
Date: | 2006-05-26 16:07:00 |
Message-ID: | Pine.BSO.4.63.0605261105140.32149@leary2.csoft.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-jdbc |
On Fri, 26 May 2006, Jay Kumar Yadav wrote:
> 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.
This question is not appropriate for this list as it has nothing to do
with java or jdbc. I would suggest trying pgsql-sql or pgsql-general.
Kris Jurka