Solved

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

Posted on 2008-06-13
2
940 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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Having an SQL database can be a big investment for a small company. Hardware, setup and of course, the price of software all add up to a big bill that some companies may not be able to absorb.  Luckily, there is a free version SQL Express, but does …
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…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

911 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

25 Experts available now in Live!

Get 1:1 Help Now