Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hi all, I'm trying to get the la 1

Status
Not open for further replies.

kenjoswe

Technical User
Joined
Sep 19, 2000
Messages
327
Location
SE
Hi all,

I'm trying to get the latest data (Date) from a Oracle table connected as a linked server to SQL7
Example:

CUSTOMER_ID_ CUST_NAME CUST_ADRESS DATE
1 A B 01
1 B A 02
1 B A 03
1 C A 04

In this exampel should the correct answer be:
1,C,A,04

I have tried with

SELECT
CUSTOMER_ID_,CUST_NAME,CUST_ADRESS,MAX(DATE)
FROM CUSTOMERS
GROUP BY
CUSTOMER_ID_,CUST_NAME,CUST_ADRESS

What have I missed?

/Kent J.





 

Try something like this.

SELECT
CUSTOMER_ID, CUST_NAME, CUST_ADRESS, [DATE]
FROM CUSTOMERS AS c
WHERE [DATE]=
(SELECT MAX([DATE]) FROM CUSTOMERS
WHERE CUSTOMER_ID=c.CUSTOMER_ID)
Terry L. Broadbent
FAQ183-874 contains tips for posting questions in these forums.
NOTE: Reference to the FAQ is not directed at any individual.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top