Often, we hear about clients trying to figure out why Foxfire! creates an SQL statement with GROUP statements and why it doesn’t. The distinction can be subtle when looking at the interface so let’s explain why.
Foxfire! does two things with a request:
- It creates the SQL statement that is used to gather the data.
- It creates a formatted report file to display the information, using the layout you have specified. If you are using a Custom Layout, then Foxfire! won’t create the formatted layout, it will use the one you created.
Let’s start by looking at two types of Foxfire! requests. When you first create a request, you choose between five different types:
- Detail
- Summary
- Cross-Tab
- Label
- Form Filler
SELECT ALL;
CARS.MAKE,;
CARS.COLOR,;
CARS.SALEDT,;
CARS.SALEPR;
FROM “CARS” CARS;
INTO CURSOR CARSDET;
WHERE (UPPER(Cars.Make) IN (“PONTIAC”,”FORD”);
AND Cars.Saledt<>{};
AND UPPER(Cars.Color) IN (“BLACK”,”BLUE”))
SELECT ALL;
CARS.MAKE,;
CARS.COLOR,;
CARS.SALEDT,;
Sum(CARS.SALEPR) AS SM_SALEPR;
FROM “CARS” CARS;
INTO CURSOR CARSDUM;
WHERE (UPPER(Cars.Make) IN (“PONTIAC”,”FORD”);
AND Cars.Saledt<>{};
AND UPPER(Cars.Color) IN (“BLACK”,”BLUE”));
GROUP BY 1, 2, 3;
ORDER BY 1, 2, 3
SELECT ALL;
CARS.MAKE,;
CARS.COLOR,;
CARS.SALEDT,;
CARS.SALEPR;
FROM “CARS” CARS;
INTO CURSOR CARSDUM;
WHERE (UPPER(Cars.Make) IN (“PONTIAC”,”FORD”);
AND Cars.Saledt<>{};
AND UPPER(Cars.Color) IN (“BLACK”,”BLUE”));
GROUP BY 1, 2, 3, 4;
ORDER BY 1, 2, 3, 4
The resulting Summary report has the same results but hides the individual columns for Make and Color, creating groups instead.
The Detail report with similar grouping shows the details but is not totalling the results. It is simply showing the Price received for each item.
In this case, the SQL is much clearer:
SELECT ALL;
CARS.MAKE,;
CARS.COLOR,;
Sum(CARS.SALEPR) AS SM_SALEPR;
FROM “CARS” CARS;
INTO CURSOR CARSDUM;
WHERE (UPPER(Cars.Make) IN (“PONTIAC”,”FORD”);
AND Cars.Saledt<>{};
AND UPPER(Cars.Color) IN (“BLACK”,”BLUE”));
GROUP BY 1, 2;
ORDER BY 1, 2