on 08-28-2015 4:15 PM
Hi all
Would like some advice on how to write a customised sales analysis query showing the Net Sales using the journal tables.
The beginning of my query is as below:
SELECT T2.[SlpName], T1.[CardCode], T1.[CardName], T0.[U_01] AS 'January Target',
SUM(CASE WHEN month(T3.[RefDate]) = '1' THEN T3.[Debit] - T3.[Credit] END) AS 'January Total'
FROM [dbo].[@SALES_TARGETS] T0
INNER JOIN [dbo].[OCRD] T1 ON T0.[Code] = T1.[CardCode]
INNER JOIN [dbo].[OSLP] T2 ON T1.[SlpCode] = T2.[SlpCode]
INNER JOIN [dbo].[JDT1] T3 ON T1.[CardCode] = T3.[ShortName]
INNER JOIN [dbo].[OJDT] T4 ON T3.[TransId] = T4.[TransId]
WHERE year(T3.[RefDate]) = '2015' AND T3.[TransType] IN ('13','14')
GROUP BY T2.[SlpName], T1.[CardCode], T1.[CardName], T0.[U_01]
This executes correctly, however the total column (debit - credit) is giving the gross total whereas I need the nett - I need to remove the tax amounts.
I can't see any obvious way of doing this - would welcome any assistance.
Many thanks
wendy
Hi Wendy ..
You can go with the sales invoice and credit memo table instead of OJDT table...
Regards,
Kennedy
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
107 | |
12 | |
11 | |
6 | |
6 | |
4 | |
4 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.