Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
What is wrong with this SQL Select
Message
 
 
To
08/02/2005 16:43:29
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00984918
Message ID:
00984934
Views:
29
If I don't use TOP n clause I get too many records. The purpose of the subquery is to select just one record, at the top. And note that the subquery by itself works, and the main query by itself work too. Just when they are put together something is missing.

Thank you for your suggestion.

>The TOP n clause work only with the GROUP BY clause. Since Reser_PK should be unique because it is the PK, you don't need the TOP n and ORDER BY clauses:
select RESER_PK, ROOM_NUM as ROOM, RES_DATE, BEGIN_TIME ;
>from RR_RESER ;
>where RESER_PK in ;
>(select RESER_PK from RR_RESER where ROOM_NUM == ROOM ;
>AND RES_DATE = DATE()) order by ROOM
HTH
>
>>What could be wrong with the following query:
>select RESER_PK, ROOM_NUM as ROOM, RES_DATE, BEGIN_TIME ;
>>from RR_RESER ;
>>where RESER_PK in ;
>>(select top 1 RESER_PK from RR_RESER where ROOM_NUM == ROOM ;
>>AND RES_DATE = DATE() order by BEGIN_TIME descending)  order by ROOM
>>
>The error I get is:
>Command is missing required clause
>The RESER_PK is a PK field.
"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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform