Solved

need to modify a select statement

Posted on 2012-03-13
2
251 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
sql server query 12 26
SQL USE DATABASE VARIABLE 5 30
MS SQL + group by time 4 15
MS SQL + date 6 24
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
I have a large data set and a SSIS package. How can I load this file in multi threading?
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
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.

820 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