query with columns calculations (1 Viewer)

NT100

Registered User.
Local time
Today, 22:04
Joined
Jul 29, 2017
Messages
148
Hi,

I've a query with columns TRef (Primary Key), SQuota, SPSQuota, SessionCnt. I need to build a query to apply the below criteria and then sort them in order of effectiveQuota.

if (SPSQuota x SessionCnt) >= SQuota then
effectiveQuota = SQuota
else
effectiveQuota = (SPSQuota x SessionCnt)

Pls. find the attached test data for the above work.

Welcome any advice on this.
 

Attachments

  • Test_data_LeastAvail.JPG
    Test_data_LeastAvail.JPG
    58 KB · Views: 45

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 22:04
Joined
May 7, 2009
Messages
19,230
create New query from your first query adding the new column:

Select TRef, SQuota, SPSQuota, SessionCnt, IIF((SPSQuota * SessionCnt) >= SQuota , SQuota, (SPSQuota * SessionCnt)) As effectiveQuota From qryTAvail_PIP1_SessionCnt Order By IIF((SPSQuota * SessionCnt) >= SQuota , SQuota, (SPSQuota * SessionCnt))
 
Last edited:

NT100

Registered User.
Local time
Today, 22:04
Joined
Jul 29, 2017
Messages
148
Thank you. It worked perfectly.
 

Users who are viewing this thread

Top Bottom