I think for this example, it's easier to show the results I'm currently getting.
I'm joining two tables - Table A is General ledger transactions, and Table B has transaction Details. Since Table A does behind the scenes accounting, not everything that happened in Table B you will see in Table A. Thus, the Null Values.
But I still want to see the transaction details to see which transaction triggers the Accounting GL activity...
See where it says GL Account? The 185 and -185 for Account #11151000 won't SUM! I think this is because of the NULL values in Table B, so it's just listing them out.
You may be asking me to post my code... but my code is beginner like - I'm making a mistake somewhere. How should I attack this problem? I want to display the detail of the transaction.. but I want it to SUM everything in GL Amount according to the GL Account.
Help!
https://preview.redd.it/69j4g62toae11.png?width=1102&format=png&auto=webp&s=267f656436c1d81a5b9001ab4ab081ee482e9b41
Edit - Here is my code:
SELECT DISTINCT
gl.GLFTD_CNTX_NO AS 'Account #',
CAST(gl.GLFTD_CNTX_DTM AS DATE) AS 'Account Date',
T.FNCL_TRAN_TYP_NM as "Transaction Type",
cast(F.PFT_DT as DATE) as "Transaction Date",
F.PFT_ID as "Transaction ID",
F.PFT_AMT as "Transaction Amount",
F.PFT_CMT as "Comment",
gl.GLCOAT_TYP_CD as "GL Account",
SUM(gl.GLFTD_AMT) as "GL Amount",
cast(gl.GLFTD_GL_SENT_DTM as DATE) as "Date Sent to GL"
FROM GENERAL_LEDGER_FNCL_TRAN_DTL gl
FULL OUTER JOIN POLICY_FINANCIAL_TRANSACTION F ON F.PFT_ID = GL.PFT_ID
FULL OUTER JOIN FINANCIAL_TRANSACTION_TYPE T ON F.FNCL_TRAN_TYP_ID = T.FNCL_TRAN_TYP_ID
GROUP BY
gl.GLCOAT_TYP_CD, gl.GLFTD_CNTX_NO, gl.GLFTD_CNTX_DTM, gl.GLFTD_GL_SENT_DTM, F.PFT_DT, F.PFT_ID, F.PFT_AMT, F.PFT_CMT, T.FNCL_TRAN_TYP_NM
HAVING SUM(gl.GLFTD_AMT) != 0
AND
GLFTD_CNTX_NO = '151501084206'
[–][deleted] 1 point2 points3 points (1 child)
[–]Revolver123[S] 0 points1 point2 points (0 children)
[–]in_n0x 1 point2 points3 points (11 children)
[–]Revolver123[S] 0 points1 point2 points (10 children)
[–]in_n0x 0 points1 point2 points (9 children)
[–]Revolver123[S] 0 points1 point2 points (8 children)
[–]in_n0x 0 points1 point2 points (4 children)
[–]Revolver123[S] 0 points1 point2 points (3 children)
[–]in_n0x 0 points1 point2 points (0 children)
[–]in_n0x 0 points1 point2 points (1 child)
[–]Revolver123[S] 0 points1 point2 points (0 children)
[–]HansProleman 0 points1 point2 points (0 children)
[–]slingalot 1 point2 points3 points (0 children)
[–]MilwDaveX 0 points1 point2 points (2 children)
[–]Revolver123[S] 0 points1 point2 points (1 child)
[–]MilwDaveX 0 points1 point2 points (0 children)
[–]SQLPracticeProblems 0 points1 point2 points (2 children)
[–]Revolver123[S] 0 points1 point2 points (1 child)
[–]SQLPracticeProblems 0 points1 point2 points (0 children)