Solved

query to find the lower values of two columns for sql server

Posted on 2008-06-13
2
937 Views
Last Modified: 2008-06-13
I have the following table columns .  
emp_no, bonus1, bonus2

I like a simple sql to find the lower value of bonus1 and bonus2, so the out_put is:
emp_no, lower_of_bonus1_bonus2
0
Comment
Question by:ewang1205
2 Comments
 
LVL 17

Accepted Solution

by:
xDJR1875 earned 300 total points
ID: 21780218
Something like the following

Select emp_no, Case When bonus1 < bonus2 Then bonus1 Else bonus2 end
from mytable
0
 
LVL 16

Assisted Solution

by:brad2575
brad2575 earned 200 total points
ID: 21780236
try this:
select emp_no, case when bonus1 < bonus2

            then bonus1

            else bonus2 end as lower_of_bonus1_bonus2

  from TableName

Open in new window

0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Suggested Solutions

Performance is the key factor for any successful data integration project, knowing the type of transformation that you’re using is the first step on optimizing the SSIS flow performance, by utilizing the correct transformation or the design alternat…
Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
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.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

757 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

19 Experts available now in Live!

Get 1:1 Help Now