Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Self Join
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Miscellaneous
Thread ID:
00525741
Message ID:
00525933
Views:
15
Farouk,

************************
Hi all VFP users/experts

I have a table as follows of employees salary data

empl_no WEF Salary
0001 01/01/1998 2000
0001 01/01/1999 2500
0001 01/01/2000 3000
0001 01/02/2001 3200

How can I construct a SQL to generate follwing cursor

empl_no WEF New Salary Old Salary
0001 01/01/1998 2000 NULL
0001 01/01/1999 2500 2000
0001 01/01/2000 3000 2500
0001 01/01/2001 3200 3000

Would appreciate all help. Thanks

*********************************

Try this.
SELECT A.Empl_No, A.Salary AS New_Salary, B.Salary AS Old_Salary, A.Wef ;
	FROM Salary A ;
	LEFT OUTER JOIN Salary B ;
	ON A.Empl_No = B.Empl_No ;
	AND YEAR(A.Wef) = YEAR(B.Wef) + 1
Regards,
Thom C.
Previous
Reply
Map
View

Click here to load this message in the networking platform