From: | Darren Greer <dgreer(at)websightsolutions(dot)com> |
---|---|
To: | pgsql-sql(at)postgreSQL(dot)org |
Subject: | Trouble with massive select statement. |
Date: | 1999-06-21 20:45:38 |
Message-ID: | 99062116013106.13060@george |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Hello all, first a bit of information.
I have the following tables:
listeners (username text, first_name text, last_name text, email text, station
char(10) );
listeners_data (username text, signup_date, zip_text text);
testmaster (username text, test_date date, station char(10) );
Now what I need to do is select all the users who have taken a test (for a
particular station) within, say the last so many number of days. The following
select statement does that. However I need the following select statement to
work inside of another select statement.
select distinct username, station
from testmaster t1
where 1 < (
select count(t2.username)
from testmaster t2
where t2.test_date > '05-14-1999'
and t2.station = 'WZZZ'
and t1.username = t2.username
)
;
I already have this select statement:
select first_name, email from listeners l, listeners_data ld where l.username = ld.username a
nd l.station = 'XXXX';
Now this select statement must only grab data if l.username exists in the data
retrieved from the first select statement I listed. This seems awefully
convoluded to me, and I expect on a large table, this could take a long time.
Therefore, I am open to any thoughts on a better way to do this. Please let me
know if you need any more information and I will be glad to provide it.
Darren
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 1999-06-21 23:29:21 | Re: [SQL] Trouble with massive select statement. |
Previous Message | Fomichev Michael | 1999-06-21 20:10:38 | Re: [BUGS] General Bug Report: CREATE TABLE AS doesn't work |