Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL TOP in Query
Message
From
16/02/2009 14:11:34
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
SQL TOP in Query
Environment versions
Visual FoxPro:
VFP 9 SP1
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01382151
Message ID:
01382151
Views:
115
Hi,

I have a query like this:
SELECT Sales.* ;
   FROM Sales ;
   WHERE iSaleID IN (SELECT TOP 2 iSaleid FROM Sales ORDER BY cInvoiceNo DESC)
The problem I'm having is due to the fact that if I have invoices entered with cInvoiceNo from "1" to "11", I want Invoices "10" and "11" to be returned, but I'm getting Invoices "1" and "11". So I really want to do something like this:
SELECT Sales.* ;
   FROM Sales ;
   WHERE iSaleID IN (SELECT TOP 2 iSaleid FROM Sales ORDER BY PADL(cInvoiceNo, 11) DESC)
but of course that gives me a syntax error.

Any ideas what I can do? I have no control over the invoice numbers as they are being returned from QuickBooks.

Thanks,
Frank.

Frank Cazabon
Samaan Systems Ltd.
www.samaansystems.com
Next
Reply
Map
View

Click here to load this message in the networking platform