I am trying to create a stored procedure using nested if, but I am not getting how to frame it. Please help me out. This if what I am trying to do:
CREATE PROCEDURE StarDistributorProfit
@sponsorId varchar(20),
AS
if exists(select sponsor_id where(select count(user_id) from usertransaction where bv=50001))
if count=1,TotalGBV=25000,TotalPBV=200
BEGIN
update usertransaction set rank='executive' where sponsor_id=@sponsorId
update usertransaction set dp=(0.309*BV)
update usertransaction set leadership_bonus=(0.07*BV)
END
if count=2,TotalGBV=20000,TotalPBV=200
BEGIN
update usertransaction set rank='star executive' where sponsor_id=@sponsorId
update usertransaction set dp=(0.318*BV)
update usertransaction set leadership_bonus=(0.03*BV)
END
if count=3,TotalGBV=20000,TotalPBV=300
BEGIN
update usertransaction set rank='Organizer' where sponsor_id=@sponsorId
update usertransaction set dp=(0.318*BV)
update usertransaction set leadership_bonus=(0.03*BV)
END
GO