Michael R Mattys
michael.mattys at adelphia.net
Thu Sep 25 12:03:48 CDT 2003
Hi Group, This is a bit difficult for me to do in SQL and I need some help: I have a table with name, address, birthdate, area and type. There are people in the same household that I need to parse out. Find duplicates based on address. Type cannot be "D" Area must be "NW" If both are type "R", get the oldest (DateDiff) If only one is type "R", show that one. If neither are type "R", show the elder. SELECT [ADD1], ID, [FullName], [CITY], [STATE], [ZIP], [TYPE], [DOB], [AREA] FROM NWP WHERE ((([ADD1]) In (SELECT [ADD1] FROM [NWP] As Tmp GROUP BY [ADD1] HAVING Count(*)>1 )) AND ((TYPE)<>"D") AND ((AREA)="NW")) AND ???? ORDER BY [ADD1]; Sample Data [ID][FullName], [ADD1], [CITY], [STATE],[ZIP],[TYPE],[DOB],[AREA] 1, Doe Jane, 1 North ST, CX, NY, 11111, C, 11/13/1973, NW 2, Doe John, 1 North ST, CX, NY, 11111, R, 01/07/1969, NW 3, Big Jane, 1 East ST, CX, NY, 11111, R, 11/13/1973, NW 4, Big John, 1 East ST, CX, NY, 11111, R, 01/07/1969, NW 5, Cat Jane, 1 West ST, CX, NY, 11111, R, 11/13/1973, NW 6, Dog John, 1 West ST, CX, NY, 11111, R, 01/07/1969, NW TIA, Mike Mattys