USE [AmazonProfitLossOrderManagement]
GO
/****** Object: StoredProcedure [dbo].[our_profit_loss] Script Date: 2020-06-19 10:17:11 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
remove-this-phrase– Alter Procedure our_profit_loss
remove-this-phrase– =============================================
remove-this-phrase– Author: <Author,,Name>
remove-this-phrase– Create date: <Create Date,,>
remove-this-phrase– Description: <Description,,>
remove-this-phrase– =============================================
CREATE PROCEDURE [dbo].[our_profit_loss]
AS
BEGIN
remove-this-phrase– SET NOCOUNT ON added to prevent extra result sets from
remove-this-phrase– interfering with SELECT statements.
SET NOCOUNT ON;
/****** Script for SelectTopNRows command from SSMS ******/
declare @customer_paid float;
declare @ur_total_cost float;
SELECT @customer_paid=([item-price-cad] + [item-tax-cad] + [shipping-price-cad] + [shipping-tax-cad] ), @ur_total_cost = ([our_purchase_price] + [our_shipping_price] + our_shipping_insurance)
FROM [AmazonProfitLossOrderManagement].[dbo].[order_and_profit_loss_mgmt_july_15th_2018]
select @customer_paid, @ur_total_cost
update [order_and_profit_loss_mgmt_july_15th_2018]
set total_customer_pay=([item-price-cad] + [item-tax-cad] + [shipping-price-cad] + [shipping-tax-cad] )
update [order_and_profit_loss_mgmt_july_15th_2018]
set our_total_cost=([our_purchase_price] + [our_shipping_price] + our_shipping_insurance)
update [order_and_profit_loss_mgmt_july_15th_2018]
set our_profit_loss=round(total_customer_pay-our_total_cost-amazon_fees_cad,2)
select * from [order_and_profit_loss_mgmt_july_15th_2018]
update [order_and_profit_loss_mgmt_july_15th_2018]
set our_purchase_price=0 where our_purchase_price is null
update [order_and_profit_loss_mgmt_july_15th_2018]
set our_shipping_price=0 where our_shipping_price is null
update [order_and_profit_loss_mgmt_july_15th_2018]
set our_shipping_insurance=0 where our_shipping_insurance is null
update [order_and_profit_loss_mgmt_july_15th_2018]
set refund_to_customer=0 where refund_to_customer is null
select * from [order_and_profit_loss_mgmt_july_15th_2018]
order by [purchase-date] desc
update [order_and_profit_loss_mgmt_july_15th_2018]
set order_cancelled=0
where order_cancelled is null
select sum(our_profit_loss) as proft, sum(our_profit_loss)*0.15 as possible_tax, sum(our_profit_loss)*0.15 as possible_vat,
(sum(our_profit_loss) – sum(our_profit_loss)*0.15) as actual_profit
from [order_and_profit_loss_mgmt_july_15th_2018]
where order_cancelled=0
END
GO
*** . *** *** . *** . *** . ***
Training Courses: http://Training.SitesTree.com
Blog: http://Bangla.SaLearningSchool.com, http://SitesTree.com
8112223 Canada Inc/Justetc: http://JustEtc.net
Youtube: https://www.youtube.com/channel/UCHrtq0pV8mEuTLGd2-Lp9ig/playlists
Medium: https://medium.com/@SayedAhmedCanada
Sayed Ahmed
BSc. Eng. in Comp. Sc. & Eng. (BUET)
MSc. in Comp. Sc. (U of Manitoba, Canada)
MSc. in Data Science and Analytics (Ryerson University, Canada)
Linkedin: https://ca.linkedin.com/in/sayedjustetc
Facebook Groups/Forums to discuss (Q & A):
https://www.facebook.com/salearningschool
https://www.facebook.com/banglasalearningschool
https://www.facebook.com/justetcsocial
Get access to courses on Big Data, Data Science, AI, Cloud, Linux, System Admin, Web Development and Misc. related. Also, create your own course to sell to others. http://sitestree.com/training/
Join, Discuss, and Thrive:
Finance: https://www.facebook.com/groups/1792339521056034
Bangladesh and Canada: https://www.facebook.com/groups/398414183875009
Bangladesh: IT & Eng: Canada: https://www.facebook.com/groups/480297675634630
BUETians in Ontario: https://www.facebook.com/groups/371982239854027
Worldwide IT: https://www.facebook.com/groups/28362061867
JustEtc: https://www.facebook.com/JustETC-Technologies-Inc-289864738261