Solved

need to modify a select statement

Posted on 2012-03-13
2
248 Views
Last Modified: 2012-03-28
Hi experts,
I need to modify the following case statement:
CASE WHEN AVG(I.Invoice_Amt)>MAX(cust.Approval_Limit)  THEN 0.75*(MAX(I.Invoice_Amt)) ELSE MAX(cust.Approval_Limit) END AS RecApprovalLimit

At THEN 0.75*(MAX(I.Invoice_Amt)) - I should also make sure 0.75*(MAX(I.Invoice_Amt))  doesnot exceed 50000, how do I incorporate the logic here, pls help
0
Comment
Question by:sqlcurious
2 Comments
 
LVL 11

Accepted Solution

by:
SANDY_SK earned 500 total points
ID: 37716745
try this

CASE WHEN AVG(I.Invoice_Amt)>MAX(cust.Approval_Limit)  
THEN (   CASE WHEN (0.75*(MAX(I.Invoice_Amt)) )>50000 then 50000 ELSE (0.75*(MAX(I.Invoice_Amt))   END      ) ELSE MAX(cust.Approval_Limit) END AS RecApprovalLimit
0
 

Author Closing Comment

by:sqlcurious
ID: 37778418
thanks
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now