X
Xcelsoft
I have discovered an unsual problem with a
grouping/totaling query. I am running Access 2000 and
have used this many times before but for some reason I am
getting strange results. To make it easy to explain I
will provide an example below.
Table1:
NAME COLOR
Emp1 Silver
Emp1 Yellow
Emp1 Gold
Emp2 Red
Emp2 Green
Emp2 Blue
Query1:
Basically selects the Name and Color field from Table1,
grouped by name and selects First Color field, ordered by
Name and Color. See below:
SELECT Table1.NAME, First(Table1.COLOR) AS FirstOfCOLOR
FROM Table1
GROUP BY Table1.NAME
ORDER BY Table1.NAME, First(Table1.COLOR);
Even though the records are sorted by Name then Color,
Ascending, the results are Emp1 Silver and Emp2 Red. The
results should be Emp1 Gold and Emp2 Blue.
If I use the Min option in the query instead of the first
option as shown below the correct results are returned.
Can anyone explain why the First (instead of Min) does
not work.
SELECT Table1.NAME, Min(Table1.COLOR) AS MinOfCOLOR
FROM Table1
GROUP BY Table1.NAME
ORDER BY Table1.NAME, Min(Table1.COLOR);
Thanks
Xcelsoft
grouping/totaling query. I am running Access 2000 and
have used this many times before but for some reason I am
getting strange results. To make it easy to explain I
will provide an example below.
Table1:
NAME COLOR
Emp1 Silver
Emp1 Yellow
Emp1 Gold
Emp2 Red
Emp2 Green
Emp2 Blue
Query1:
Basically selects the Name and Color field from Table1,
grouped by name and selects First Color field, ordered by
Name and Color. See below:
SELECT Table1.NAME, First(Table1.COLOR) AS FirstOfCOLOR
FROM Table1
GROUP BY Table1.NAME
ORDER BY Table1.NAME, First(Table1.COLOR);
Even though the records are sorted by Name then Color,
Ascending, the results are Emp1 Silver and Emp2 Red. The
results should be Emp1 Gold and Emp2 Blue.
If I use the Min option in the query instead of the first
option as shown below the correct results are returned.
Can anyone explain why the First (instead of Min) does
not work.
SELECT Table1.NAME, Min(Table1.COLOR) AS MinOfCOLOR
FROM Table1
GROUP BY Table1.NAME
ORDER BY Table1.NAME, Min(Table1.COLOR);
Thanks
Xcelsoft