Re: [SQL] Need SQL Help Finding Current Status of members

2005-12-18 Thread Michael Fuhr
On Sat, Dec 17, 2005 at 07:34:22PM -0500, Michael Avila wrote: > The table is not empty. I did some playing around with the SQL Statement but > got no where. So I added a record status column that will be non-NULL when > the status becomes history because a new status is added. Yeah, I cheated to >

Re: [SQL] Need SQL Help Finding Current Status of members

2005-12-17 Thread Michael Avila
for the help. Mike > -Original Message- > From: Michael Fuhr [mailto:[EMAIL PROTECTED] > Sent: Saturday, December 17, 2005 7:26 PM > To: Michael Avila > Cc: SQL PostgreSQL MailList > Subject: Re: [SQL] Need SQL Help Finding Current Status of members > > > On

Re: [SQL] Need SQL Help Finding Current Status of members

2005-12-17 Thread Michael Fuhr
On Fri, Dec 16, 2005 at 07:44:46PM -0500, Michael Avila wrote: > Just tried it and it returned nothing. > > > > Select * from memberstatus A where not exists > > >(select * from emberstatus B where B.member_id=A.member_id and > > > B.status_date >A.status_date) > > Why the WHERE NOT EXISTS?

Re: [SQL] Need SQL Help Finding Current Status of members

2005-12-16 Thread Michael Avila
ROTECTED] > > [mailto:[EMAIL PROTECTED] Behalf Of Patrick JACQUOT > > Sent: Friday, December 16, 2005 5:12 AM > > Cc: SQL PostgreSQL MailList > > Subject: Re: [SQL] Need SQL Help Finding Current Status of members > > > > > > Richard Huxton wrot

Re: [SQL] Need SQL Help Finding Current Status of members

2005-12-16 Thread Alvaro Herrera
Michael Avila wrote: > Interesting. I think I understand that. I have never worked with a SELECT > within a SELECT (I think that is called a subquery). I am guessing that it > works its way through the member status records until the latest date > "floats" to the top (nothing is > than it). > > Wil

Re: [SQL] Need SQL Help Finding Current Status of members

2005-12-16 Thread Michael Avila
m performance-wise if there are thousands of records? Thanks for the help. Mike > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] Behalf Of Patrick JACQUOT > Sent: Friday, December 16, 2005 5:12 AM > Cc: SQL PostgreSQL MailList > Subject:

Re: [SQL] Need SQL Help Finding Current Status of members

2005-12-16 Thread Patrick JACQUOT
Richard Huxton wrote: Michael Avila wrote: I have a table which keeps track of the status of members. In the table is member_id int(8) status_code char(1) status_date date KEY member_id (member_id,status_code,status_date) Each member can have multiple records because a record is added each

Re: [SQL] Need SQL Help Finding Current Status of members

2005-12-16 Thread Richard Huxton
Michael Avila wrote: I have a table which keeps track of the status of members. In the table is member_id int(8) status_code char(1) status_date date KEY member_id (member_id,status_code,status_date) Each member can have multiple records because a record is added each time the status chan

Re: [SQL] Need SQL Help Finding Current Status of members

2005-12-15 Thread Michael Fuhr
On Thu, Dec 15, 2005 at 08:31:09PM -0500, Michael Avila wrote: > What I want to do is find the latest status for each member. Actually I want > to find all those with an status of "A". But it must be the current (latest) > status. How do I find the most current date for each member in a pile of > m

[SQL] Need SQL Help Finding Current Status of members

2005-12-15 Thread Michael Avila
I have a table which keeps track of the status of members. In the table is member_id int(8) status_code char(1) status_date date KEY member_id (member_id,status_code,status_date) Each member can have multiple records because a record is added each time the status changes but the old record i