From: Jay Kumar Yadav <jaykumaryadav1980@rediffmail.com>
To: pgsql-jdbc@postgresql.org
Subject: Query Related to Check Individual Values of Range!!!
Date: 26 May 2006 14:05:08 -0000
Message-ID: <20060526140508.8154.qmail@webmail64.rediffmail.com> (raw)
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.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: jaykumaryadav1980@rediffmail.com
Subject: Re: Query Related to Check Individual Values of Range!!!
In-Reply-To: <20060526140508.8154.qmail@webmail64.rediffmail.com>
References: <20060526140508.8154.qmail@webmail64.rediffmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox