Re: how to query from two identical tables?**Help needed urgent**



jayend5000@xxxxxxxxx wrote:
table A



id - f1 - f2 - date
1 1 a Mar 9 2006 8:50PM
1 2 b Mar 9 2006 8:50PM
1 3 c Mar 9 2006 8:50PM
1 4 d Mar 9 2006 8:50PM
1 5 e Mar 9 2006 8:50PM
2 1 x Mar 19 2006 8:50PM
2 2 z Mar 1 2006 8:50PM
2 3 t Mar 19 2006 8:50PM
2 4 u Mar 1 2006 8:50PM
2 5 p Mar 19 2006 8:50PM


table B

id - f1 - f2 - date

2 1 a1 Mar 1 2006 8:50PM
2 2 b1 Mar 9 2006 8:50PM
2 3 c1 Mar 19 2006 8:50PM
2 4 d1 Mar 9 2006 8:50PM
2 5 e1 Mar 19 2006 8:50PM

expected result:

id - f1 -f2 - date ((ONLY for common ids and
f1))

2 1 x Mar 19 2006 8:50PM
2 2 b1 Mar 9 2006 8:50PM
2 3 t Mar 19 2006 8:50PM
2 4 d1 Mar 9 2006 8:50PM
2 5 p Mar 19 2006 8:50PM






1. ids are common to A and B
2. f1 may be one among the values (1,2,3,4,5)
3. key fields are id and f1
4. query needed to get the latest f2 value based on the latest date
(date field)
3. f3 is some character value
4. date is date filed of format MON DD YYYY hh:mmAM


Do you want someone to write the SQL statement for you or is there
some work you've done that you would like help fixing?
--
Daniel A. Morgan
http://www.psoug.org
damorgan@xxxxxxxxxxxxxxxx
(replace x with u to respond)
.



Relevant Pages