Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ech month jobs sales

Status
Not open for further replies.

codrutza

Technical User
Mar 31, 2002
357
IE
Hello

SQL Server 2000, CrystalReportsXI
Maybe you help me with this:

I have to write a stored procedure.
I have to print for current year up to current month (excluded) and for previous year, in each month, sums like that:
2010
Jan Feb … May Jun …. December Total
Russia jobs … … … 50 2000
Russia kg … … … 40 4000
Russia sales … … … 300 6000
Client X jobs … … … 10 100
Client X kg … … … 3 50
Client X sales … … … 200 400
Others jobs … … … 100 3000
Others kg … … … 50 5000
Others sales … … … 40 7000
2009 –the same layout but filled completely
I have to write in select
SELECT
Customers.Name AS CName,
Customers.AccNo,
….
JobA.Cargo,
JobA.TEUs,
JobA.JobNumber,
JobA.CompanyJob,
JobA.CompanyPartner,
JobA.TransportA,
JobA.TransportR,
Jobs.ReadyDate,
Jobs.ReportingDate

Sum( for each month from reporting date for the client for the area for others),

FROM (JobA WITH (READUNCOMMITTED)
INNER JOIN Jobs WITH (READUNCOMMITTED)
ON JobA.JobNo=Jobs.JobNo)
INNER JOIN Customers WITH(READUNCOMMITTED)
ON Customers.AccountNo=Jobs.CustomerAccountNo
AND JobA.Type in ('Import','Export')
AND JobA.CompanyForT='AA'
……
AND JobA.CargoType IN ('F/F', 'L/F')
AND JobA.Via='Sea'
AND
(
(JobA.CompanyJob in ('B', 'D') and JobA.CompanyPartner='AA')
OR
(JobA.CompanyJob ='AA' and JobA.Type='Import')
)
AND Jobs.ReportingDate<>'2001-01-01 00:00:00'
AND Jobs.ReadyDate<>'2001-01-01 00:00:00'

WHERE
????

@Year(ReportingDate) <=crt year until the crt. month or previous year

SELECT @c_result=@@ERROR
RETURN @c_result
GO

I am beginner in SP.

Thank you
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top