Link to home
Start Free TrialLog in
Avatar of DColin
DColinFlag for Thailand

asked on

SQL query.

Hi Experts,

I want to select all customer names from a table that share the highest ID. The following sql shows what I want to do but does not work.

SELECT CustomerName FROM tblCustomers WHERE ID = MAX(ID)
ASKER CERTIFIED SOLUTION
Avatar of dsacker
dsacker
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I cannot imagine why this would bring back more than one record, as you generally don't repeat ID values, and:

SELECT Max([ID]) from tblCustomers

would only return a single ID value.

Can you describe (in words, not SQL) what it is you really want to accomplish?  

You may have to provide  a little more detail about your table structure.  If you could provide a couple of sample records (sanitized to avoid revealing personal, financial, or proprietary information) , that would be even better.