Solved

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

Posted on 2008-06-13
2
955 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 17

Accepted Solution

by:
Daniel Reynolds 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
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…
Viewers will learn how the fundamental information of how to create a table.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

696 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