Compress query display

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello:
I have a query showing result like
ID Year Field1 Field 2 Field3
1 2005 Y Y
1 2005 Y
1 2005 Y

How can I show the result in one line as a summary, i.e.
ID Year Field1 Field 2 Field3
1 2005 Y Y Y

Thanks in advance!
 
Hi,



SELECT ID, year, MAX(field1), MAX(field2), MAX(field3)
FROM mytable
GROUP BY ID, year


The MAX() aggregation exclude NULL, so, if there is a not null value, it
will be kept. Note you can also use MIN( ) instead of MAX( ), if this is
more appropriate.


Hoping it may help,
Vanderghast, Access MVP
 
It works. Thanks a lot!


Michel Walsh said:
Hi,



SELECT ID, year, MAX(field1), MAX(field2), MAX(field3)
FROM mytable
GROUP BY ID, year


The MAX() aggregation exclude NULL, so, if there is a not null value, it
will be kept. Note you can also use MIN( ) instead of MAX( ), if this is
more appropriate.


Hoping it may help,
Vanderghast, Access MVP
 
Back
Top