Shipping Price (1 Viewer)

24sharon

Registered User.
Local time
Today, 06:50
Joined
Oct 5, 2004
Messages
147
I want to make stored Procedure that get sum total of the order and return the ship price

my table schema attach :

in my procedure I want to get the order subTotal and return the ship price

For example if the subTotal is 60$ than return 300$

etc,

my problem is that if the "toPrice" = 0, than its mean "higher than"

How can I Write this Code, here is my try:

Code:
declare @subTotal int
set @subTotal = 60


SELECT [ShippingPolicyId]
      ,[Header]
      ,[fromPrice]
      ,[toPrice],[price]
  FROM [dbo].[xxx_ShippingPolicy]
where @subTotal >=[fromPrice] and    @subTotal <= [toPrice]
--where @subTotal >=[fromPrice] and case when [toPrice] > 0 then   @subTotal <= [toPrice] else 1=1
 

Attachments

  • untitled1.JPG
    untitled1.JPG
    22 KB · Views: 135

pbaldy

Wino Moderator
Staff member
Local time
Today, 06:50
Joined
Aug 30, 2003
Messages
36,118
Rather than zero as a toPrice, I would use 9999999 (or some number in excess of anything you sell). That way you can use a non-equi join or lookup to get the shipping.
 

Users who are viewing this thread

Top Bottom