1

I've created a report based on this query:

SELECT sum(IIF(foo=True, 1, 0)), sum(IIF(bar=True, 1, 0)) from xy;

So I get the following result:

+---------+---------+----------+
|   Foo   |   Bar   |   ...    |
+---------+---------+----------+
| Value 1 | Value 2 | ...      |
+---------+---------+----------+

And then I generate a report from that result:

enter image description here

My question is; how do I order the values in ascending or descending order?

1 Answer 1

1

One does not normally "sort" (i.e., change the order of) fields in a report. Controls are bound to fields, and controls (usually) have a fixed location in the report layout.

I think you want to do something more like this instead:

Create a query that puts the sums into rows instead of columns...

SELECT "foo" AS Item, SUM(IIf(foo = True, 1, 0)) AS Total FROM xy
UNION ALL
SELECT "bar" AS Item, SUM(IIf(bar = True, 1, 0)) AS Total FROM xy

...and then use the resulting rows...

Item  Total
----  -----
foo      12
bar       8

...in a report. You can sort the rows in the usual way, i.e., via the "Group and Sort" button on the "Design" tab.

1
  • Thanks for the reply. I'm a little rusty on sql. I'm aware of unions but I've never needed to apply them. I'll let you know how it goes.
    – Sheldon
    Apr 10, 2013 at 9:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.