Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Complex Query
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
Complex Query
Divers
Thread ID:
00421217
Message ID:
00421217
Vues:
37
I'm trying to do a complex query and I can't seem to get the syntax right. I have 3 db's that are part of an invoice system (customer, summary and detail).

I want to select customers in GA (customer.bill_state) who's sales over the last 12 months is over $1,000 (sum(summary.total)) who have never bought an inventory item that starts with 'SE' (substr(detail.inv_id,1,2))

This probably is not that complex, but I'm having a hard time creating the sql statement to do it.

The following is generated from the Foxpro Query. But it does not work. The problem is I need to first pull out those who have never bought an 'SE' product, then somehow total sales in the last year pull ones that are over $1,000.

SELECT Customer.name, Customer.bil_add1, Customer.bil_add2,;
Customer.bil_add3, Customer.bil_city, Customer.bil_st, Customer.bil_zip,;
Customer.title, Customer.first, Customer.last;
FROM customer INNER JOIN summary;
INNER JOIN detail;
INNER JOIN ;
INNER JOIN summary;
INNER JOIN summary ;
ON sum(summary.total) > 1000.00 ;
ON Summary.shp_date >= (date()-365) ;
ON substr(detail.inv_id,1,2) <> 'SE' ;
ON Summary.inv_num = Detail.inv_num ;
ON Customer.cust_id = Summary.cust_id;
WHERE Customer.bil_st = "GA"

Is sql powerful enough to solve my problem or should I just write a program to do this?

Thanks!
Marvin Masson
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform