Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
UNION SELECT... please correct me
Message
From
27/10/1998 07:54:20
 
 
To
27/10/1998 07:20:18
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00150818
Message ID:
00150844
Views:
17
>Denis,
>Top n requires "order by" and you can't use two "order by" for a union. Unfortunately you should divide it into 3 SQLs (if ever there is a better way I don't know it).
SELECT TOP 1 * ;
>  FROM myDatabase!myTable ;
>  WHERE myTable.cod = pCod ;
>  AND myTable.price >=pPrice ;
>  into cursor crsPass1 ;
>ORDER BY mytable.price
>
>SELECT TOP 1 * ;
>  FROM myDatabase!myTable ;
>  WHERE myTable.cod = pCod ;
>  AND myTable.price <=pPrice ;
>  into cursor crsPass2 ;
>ORDER BY mytable.price DESC
>
>select * from ;
>  crsPass1 ;
>  UNION ;
>  select * from crsPass2 ;
>INTO CURSOR curPrice
Cetin


Hi Cetin.
I have already done like this.I believed, that it is possible to make operation in one SELECT. Probably so it is impossible.
Thanks again.
Denis.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform