472,122 Members | 1,414 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Max of Two Numbers in SQL - What function is available?

I am trying to figure out a way to find the max of two numbers in access, and then multiply whatever the max is by 0.008.
For example:
2019 Sales - $9,634.33
2020 Sales - $3,466.37
Find the max of the two and multiply by 0.008.

Hopefully I am explaining this well. The 2019 and 2020 sales differ for each company, so not everyone's 2020 sales will be greater than their 2019 and vice versa.
Dec 22 '20 #1
1 1613
NeoPa
32,497 Expert Mod 16PB
Hi there.

Are you calculating this from within a query or from VBA?

Either way you can use the IIf() function but illustrating it changes based on your usage.

Query (SQL) :
Expand|Select|Wrap|Line Numbers
  1. IIf([2019 Sales]>[2020 Sales],[2019 Sales],[2020 Sales])*0.008
VBA :
Expand|Select|Wrap|Line Numbers
  1. X = IIf(dbl2019Sales > dbl2020Sales, dbl2019Sales, dbl2020Sales)*0.008
Dec 22 '20 #2

Post your reply

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

Similar topics

9 posts views Thread by Rowan Chapman | last post: by
10 posts views Thread by Ken VdB | last post: by
1 post views Thread by Yannick Warnier | last post: by
reply views Thread by Raymond L. Buvel | last post: by
reply views Thread by leo001 | last post: by

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.