473,406 Members | 2,377 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

In query ,search largest number from 3 different cloumns and show it in new column

Hi,
In access 2010,I have one query based on a table.There are 3 different columns:
Commission 1, Commission 2 and Commission 3.
4th column is: Total Commission
So i want query automatically search the largest number in 3 above columns and add 10 and that has to be showed in 4th column.
Please assist me that is it possible in query or in its related form.

Thanks in advance.
Oct 13 '14 #1

✓ answered by jforbes

While in Design View of your Query, from the Ribbon, select SQL View.
Or
Since what you are most in need of adding is the Switch Statement, you can just copy and paste:
Expand|Select|Wrap|Line Numbers
  1. Switch(
  2.    [Commission 1]>=[Commission 2] And [Commission 1]>=[Commission 3],[Commission 1]
  3.   ,[Commission 2]>=[Commission 1] And [Commission 2]>=[Commission 3],[Commission 2]
  4.   ,[Commission 3]>=[Commission 1] And [Commission 3]>=[Commission 2],[Commission 3]
  5.   )+10 AS [Total Commission]
into the Field portion of the Query in Design View and modify it to fit your purpose.

4 1207
jforbes
1,107 Expert 1GB
I think you are looking for something like:
Expand|Select|Wrap|Line Numbers
  1. SELECT Commissions.[Commission 1]
  2. , Commissions.[Commission 2]
  3. , Commissions.[Commission 3]
  4. , Switch(
  5.   [Commission 1]>=[Commission 2] And [Commission 1]>=[Commission 3],[Commission 1]
  6.  ,[Commission 2]>=[Commission 1] And [Commission 2]>=[Commission 3],[Commission 2]
  7.  ,[Commission 3]>=[Commission 1] And [Commission 3]>=[Commission 2],[Commission 3]
  8.  )+10 AS [Total Commission]
  9. FROM Commissions;
If you were using TSQL, you would use the SELECT CASE

You could also use a function if this is something you plan on doing more than once, that way you would have only one place to maintain the code.
Oct 13 '14 #2
Thanks for the reply but how can i use select in 'MS Access query' and where i have to put that code. Sorry for asking again.Please be more specific.
Thanks
Oct 13 '14 #3
jforbes
1,107 Expert 1GB
While in Design View of your Query, from the Ribbon, select SQL View.
Or
Since what you are most in need of adding is the Switch Statement, you can just copy and paste:
Expand|Select|Wrap|Line Numbers
  1. Switch(
  2.    [Commission 1]>=[Commission 2] And [Commission 1]>=[Commission 3],[Commission 1]
  3.   ,[Commission 2]>=[Commission 1] And [Commission 2]>=[Commission 3],[Commission 2]
  4.   ,[Commission 3]>=[Commission 1] And [Commission 3]>=[Commission 2],[Commission 3]
  5.   )+10 AS [Total Commission]
into the Field portion of the Query in Design View and modify it to fit your purpose.
Oct 13 '14 #4
HATS OFF! Thank you so much for assisting me..Thanks a lot
Oct 13 '14 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: sunilkeswani | last post by:
Hi I am still new to access. I want to know how i can build a query which can display results from 4 different columns/fields Like. Field1 Field2 Field3 Field4 1 2 1 ...
3
by: ankitamca85 | last post by:
query to get number of columns in table ???????????
0
by: KevLe | last post by:
I'm building a log search function in c# for a certain management app and would like some help on the design how to solve this, here is my solution (on paper) so far: The log files are saved to...
1
karthickkuchanur
by: karthickkuchanur | last post by:
how to find the seventh largest number in a column for example 1,2,3,4,5,6,7
2
by: Deven Oza | last post by:
Hi, Does anyone have an idea that how to copy column(s) from one excel sheet to another sheet using sql server. Thanks for your help in advance. -Deven
1
by: joe22 | last post by:
I made a list of random numbers. From that list, how can I find the largest number and the corresponding month?
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.