troubleshooting Question

Help modifying query to honor min and max markups

Avatar of Eddie Shipman
Eddie ShipmanFlag for United States of America asked on
2 Comments1 Solution126 ViewsLast Modified:
I need modify this query to honor the minmk and maxmk, if mt = 'P' and either minmk and maxmk exist.
Not sure how to do that...

Currently, the query returns 125.00 for the first record and 2893.75. It needs to return 140.00 and 2815.00

Note: There are only 'P' (percentage) and 'F' (flat) markup types.

    -- when the markup is a 'P' (percentage) multiply     
               FROM p.markups c0 
               WHERE = 'M07' AND 
            = 'M34' AND 
            = '107') = 'P' THEN
		TO_CHAR(u.price + (u.price * (SELECT 
		                                FROM p.markups c1 
		                                WHERE = 'M07' AND 
		                             = 'M34' AND 
		                             = '107')) , 'FM999999999.00')
	-- when the markup is a 'F" (flat), so add it
		TO_CHAR(u.price + (SELECT 
		                    FROM p.markups c2 
		                    WHERE = 'M07' AND 
		                 = 'M34' AND 
		                 = '107') , 'FM999999999.00')
	END as mkprice	
FROM u.unet u
WHERE = 'M34' AND = '107'
If I have this data in `p.markups`:
"id" , "pid", "pt" , "mt", "mk", "minmk", "maxmk", "exc"
"M07", "M34", "107", "P" , 0.25, 40     , 500    , 0
and this data in u.unet:
"id",  "pt" , "price"
"M34", "107",  100.00
"M34", "107", 2315.00
Jan Louwerens
Engineering Manager

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros