Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Joining to a single record in a child record
Message
De
05/10/2004 16:27:26
 
 
À
Tous
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Titre:
Joining to a single record in a child record
Divers
Thread ID:
00948927
Message ID:
00948927
Vues:
72
Okay I have a customer table with a child table with multiple records.

I need to select data from the parent table and join it the last record from the child table based upon a datetime field.

Something like this but without the error.

select customerid, AH.* from customer
LEFT OUTER JOIN (select top 1 customerid, agentid, inserteddatetime
from activityhistory AH
where AH.customerid = customer.customerid
order by inserteddatetime desc )
on AH.customerid = customer.customerid


The Error is:
Server: Msg 156, Level 15, State 1, Line 6
Incorrect syntax near the keyword 'on'.

I know it can be done, I've seen it before but I just can't remember where.
Fred Lauckner

You know, it works on my computer. I don't know what your problem is.

.Net aint so bad.
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform