Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Stumped: sub-select with TOP
Message
 
 
À
08/02/2005 16:45:46
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00984923
Message ID:
00984955
Vues:
21
>I'm trying to help Dmitry in the 'Can this be done...' thread.
>
>It seems like the following SQL statement should do what he wants but it gets the error "Command is missing required clause".
>
>
>select KEYFIELD, CUST_ID as CUSTOMER, ORD_DATE, ORD_TIME 	;
>from ORDERTABLE	;
>where KEYFIELD in	;
>(select top 1 KEYFIELD from ORDERTABLE where CUST_ID == CUSTOMER order by ORD_DATE, ORD_TIME descending)
>order by CUSTOMER
>
>
>The sub-select works fine by itself.
>
>I simplified the statement this way but it still gets the error.
>
>select ORDERTABLE.KEYFIELD, ORDERTABLE.CUST_ID as CUSTOMER, ORDERTABLE.ORD_DATE, ORDERTABLE.ORD_TIME 	;
>from ORDERTABLE	;
>where KEYFIELD in	;
>(select top 1 ORDERTABLE.KEYFIELD from ORDERTABLE order by ORD_TIME )
>
>
>If I substitute ALL for TOP 1, the error goes away.
>
>Any ideas?

Peter,

The TOP clause must have GROUP BY. Which I added in the subquery but it still gives me an error.

Thank you for your help.

>
>Peter
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform