V
V
vista1x2015-03-07 16:47:06
SQL
vista1x, 2015-03-07 16:47:06

Custom calculated field with condition?

Hello!
I work with MS Access. There is a query that displays information of the following form:

ID_sGroupNummethodMaxCur
oneoneone20eighteen
one20tenten

The task is the following: it is necessary to calculate one more column and display it (for example, 'Result') already from another query. The calculation should be made as follows (I will try to describe in pseudo-language)
если Method == 1 тогда
    если Max == Cur тогда
        Result = Max
    иначе Result = 0
иначе Result = Cur

Those. The result should be the following table:
ID_sGroupNummethodMaxCurresult
oneoneone20eighteen0
one20tententen

How to implement this, and is it even possible to implement this?
I will be grateful for any help!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
vista1x, 2015-03-07
@vista1x

It turned out to be quite simple:

iif(Method,
   iif(Cur = Max, Max, 0)
  ,Cur
) AS Result

I don't know if this is the right way to do it, but it works.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question