Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2008-06-13
2
Medium Priority
?
967 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 1200 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 800 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Ready to get certified? Check out some courses that help you prepare for third-party exams.
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.

618 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