Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Joining tables results Post Reply Post New Topic
Author Message
Barb
Newbie
Newbie


Joined: 15 Nov 2011
Online Status: Offline
Posts: 29
Quote Barb Replybullet Topic: Joining tables results
     Posted: 14 Dec 2011 at 5:23am
Hello All
 
 
I have transformed my profit and loss report by employee into a more detailed account listing and have added few additional fields to the below formula (extract):
 
Declare @yr int, @pr int
SET @yr = {?yr1}
SET @pr = {?pr1}
SELECT Q1.*, Q2.*, pvt2.*, Qr3.* FROM
(SELECT 'JE ' + RTRIM(c.TransId) AS DocNum, c.RefDate, c.Account,c.U_P11D, c.Debit-c.Credit+c.VatAmount AS LineTotal, c.SYSDeb-c.SYSCred+c.SYSVatSum AS SysTotal,
c.LineMemo AS RowDescription, d.Ref2, d.Memo AS JournalRemarks, d.TaxDate,
c.TransId, c.FinncPriod, f.Year, e.SubNum, e.F_RefDate, e.T_RefDate, f.F_RefDate as F_YDate, f.T_RefDate as T_YDate,
g.AcctName, g.ActType,g.AcctCode, g.FatherNum, g.Levels,g.GrpLine, g.GroupMask, h.AcctName AS Father, OADM.CompnyName, OADM.MainCurncy, OADM.SysCurrncy
From JDT1 c
INNER JOIN OJDT d on c.TransId = d.TransId
INNER JOIN OFPR e on e.AbsEntry=c.FinncPriod
INNER JOIN OACP f on f.PeriodCat=e.Category
INNER JOIN OACT g on g.AcctCode=c.Account
INNER JOIN OACT h on h.AcctCode=g.FatherNum, OADM
WHERE f.Year = @yr AND e.SubNum <= @pr AND d.TransType not in (13,14,18,19)
UNION ALL
SELECT 'IN ' + RTRIM(d.DocNum) AS DocNum, c.DocDate, c.AcctCode,c.U_P11D, c.PriceAfVAT*-1 AS LineTotal, (c.TotalSumSy+c.VatSumSy)*-1 AS SysTotal,
c.Dscription AS RowDescription, d.NumAtCard AS Ref2, d.JrnlMemo AS JournalRemarks, d.TaxDate,
d.TransId, c.FinncPriod, f.Year, e.SubNum, e.F_RefDate, e.T_RefDate, f.F_RefDate as F_YDate, f.T_RefDate as T_YDate,
g.AcctName, g.ActType,g.AcctCode, g.FatherNum, g.Levels,g.GrpLine, g.GroupMask, h.AcctName AS Father, OADM.CompnyName, OADM.MainCurncy, OADM.SysCurrncy
From INV1 c
INNER JOIN OINV d on d.DocEntry = c.DocEntry
INNER JOIN OFPR e on e.AbsEntry=c.FinncPriod
INNER JOIN OACP f on f.PeriodCat=e.Category
INNER JOIN OACT g on g.AcctCode=c.AcctCode
INNER JOIN OACT h on h.AcctCode=g.FatherNum, OADM
WHERE f.Year = @yr AND e.SubNum <= @pr
 
 
The problem I have now is that when I run my report for period 6, transactions from all periods are being shown (transaction date, reference, description) but with the amount 0. I do not want to show any transactions that are not posted in period 6.
 
Please help!! What am I missing?
 
many thanks
 
 
 
Many thanks
Barb
IP IP Logged
comatt1
Senior Member
Senior Member
Avatar

Joined: 19 May 2011
Online Status: Offline
Posts: 337
Quote comatt1 Replybullet Posted: 14 Dec 2011 at 8:34am
why are you looking at <=@pr, if you need a single period, wouldnt you just want =@pr?
 
 
IP IP Logged
Barb
Newbie
Newbie


Joined: 15 Nov 2011
Online Status: Offline
Posts: 29
Quote Barb Replybullet Posted: 19 Dec 2011 at 10:36pm
Matt, thank you very much!
Many thanks
Barb
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum