Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Combining two tables
Message
From
27/07/2012 09:59:21
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Combining two tables
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Network:
Windows 2008 Server
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01549418
Message ID:
01549418
Views:
84
I need some select/SQL advice please

I am combinging two tables T1 & T2 they have customer numbers/Custno and quarter sales totals/qs

T1 contains data for the year 2010 T2 contains data from the year 2011

Data example is something like this;
T1.Custno     T1.QS
001                   $150.00
004                   $650.00
008                   $50.00
012                    $70.00
060                    $95.00

 
T1.Custno     T1.QS
001                   $350.00
002                   $550.00
008                   $750.00
035                    $10.00
060                    $595.00
I want to create a comparison table that includes all the records of both tables, but I want to match up the customers when they are the same.
I know I can do it with a scan/endscan type sort with conditions, but I was wondering if there was an easier way to do it with a select statement.

the resulting table would look like this
Custno               2011_QS            2010_QS
001                   $350.00                    $150.00
002                   $550.00                     $0.00
004                   $0.00                        $650.00                     
008                   $750.00                    $50.00
012                    $0.00                        $70.00
035                    $10.00                       $0.00
060                    $595.00                    $95.00
Thanks....
Next
Reply
Map
View

Click here to load this message in the networking platform