cancel
Showing results for 
Search instead for 
Did you mean: 

Special prices with gross profit query

former_member239716
Participant
0 Kudos

Hi guys is there anyway that I could calculate gross profit in the below query without having to dump it into excel? So that we can run the report and it shows the gross profit on each line of the customers special pricing.

SELECT T1.[CardCode] AS 'BP Code', T1.[ItemCode] AS 'Item No.', T1.[Price] AS 'Special Price', T0.[LastPurPrc] AS 'Last Purchase Price' FROM [dbo].[OITM] T0 INNER JOIN [dbo].[OSPP] T1 ON T1.[ItemCode] = T0.[ItemCode]

WHERE T1.CardCode = [%0]

View Entire Topic
Johan_H
Active Contributor

Hi Roy,

Please give this a try:

SELECT T1.[CardCode] AS 'BP Code'
     , T1.[ItemCode] AS 'Item No.'
     , T1.[Price] AS 'Special Price'
     , T0.[LastPurPrc] AS 'Last Purchase Price' 
     , (T1.[Price] - T0.[LastPurPrc]) AS 'Gross Profit'
FROM [dbo].[OITM] T0 
     INNER JOIN [dbo].[OSPP] T1 ON T1.[ItemCode] = T0.[ItemCode]
WHERE T1.CardCode = '[%0]'

Regards,

Johan