Return max value

C

Carlos

Hello i have a table

| Emp | A | B | C |
| 10 | 2 | 4 | 6 |
| 16 | 7 | 8 | 1 |

it is possible in one query return the value 8 in this exemple.

Thank
 
C

Carlos

Hi '69 Camaro

I not explain proper.

I need a query to look in column A, B and C and return the max value,
it is possible that max is in the column C, but in the example
i need return 8 locate in column B Emp 16

thank's
 
D

Duane Hookom

It looks like you table might be un-normalized so a select from a
normalizing union query should work:

SELECT Max(TheValue) as TheMax
FROM (SELECT Emp, A as TheValue, "A" as Col
FROM tblNoName
UNION ALL
SELECT Emp, B, "B"
FROM tblNoName
UNION ALL
SELECT Emp, C, "C"
FROM tblNoName) S;
 
6

'69 Camaro

Hi, Carlos.

If you're looking for a max value among multiple columns in a table, then
there's a high probability that your table is not normalized. While Duane
Hookum has already posted a query that will work, you should also look into
normalizing this table to safeguard data integrity and prevent data
anomolies in queries.

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips and tutorials.
http://www.Access.QBuilt.com/html/expert_contributors2.html for contact
info.
 
C

Carlos

Thank's for support Duane Hookom and '69 Camaro, i go to normalize the
table.

One more time than's for quick support

carman68
 
Top