Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to combine table/cursor into one using SQL-Select
Message
From
15/02/2014 06:30:16
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
How to combine table/cursor into one using SQL-Select
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01594386
Message ID:
01594386
Views:
54
Hi

Input
-----
myur1 = '2012'
myur2 = '2013'

dt1 = {01/01/&myur1}
dt2 = {31/12/&myur2}
mGrp = "CARREFOUR"

OutPut
------
Month-wise breakup comparison as follows:

Month---2013---2012--- Change---%age
------------------------------------------------------
Jan
Feb
Mar
..
..
Dec

Now I have four tables as follows:

1. Group
2. Simain
3. Sisub
4. Pcode

1. ( Group File contain multiple party code relating to the same group )
pcode c(10)
cGroup c(52)

2. ( Sales Invoice Master File contains date in which I want to filter records )
sino c(8)
pcode c(10)
invdate d && Filter = From Jan 1, 2012 to Dec 31, 2013
location c(52)

3. ( Sales Invoice Transaction File contain Quantity and Rate )
sino c(8)
icode c(10)
QntyMaj n(10,3)
QntyMin n(10,3)
RateMaj n(10,3)
Ratemin n(10,3)

4. Customer Master File contains all party information
pcode c(10)
full_name c(52)

I am using the following at the moment to get the result
Select talias1.sino, talias1.invdate, talias1.pcode, talias1.location ,talias1.zone, talias1.salesman, talias1.merchand, ;
   talias2.icode, talias2.qntymaj, talias2.qntymin, talias2.ratemaj, talias2.ratemin ;
   from simain talias1, sisub talias2 ;
   where talias1.sino = talias2.sino And Between(invdate,dt1,dt2) AND pcode # 'CP011' ;
   into Cursor sijunk Readwrite 
and then
Sele Year(invdate) As theyear, ;
   MONTH(invdate) as themonth,;
   pcode As pcode, ;
   sum(qntymaj) As cartons, ;
   sum(qntymin) As units, ;
   sum(Iif(ratemin#0,qntymin*ratemin,qntymaj*ratemaj)) As mamount, ;
   CAST('' As c(52)) As cGroup ;
   from sijunk ;
   group By theyear, themonth, pcode ;
   into Curs tempsi 
Then I run do whil ... enddo to get the group name with Group.dbf which is a time consuming job and I want to only CARREFOUR Group Data.

Can I combine all to get the result in one syntax?

Thanks

Saif
Next
Reply
Map
View

Click here to load this message in the networking platform