Solved

SQL query.

Posted on 2013-05-24
3
253 Views
Last Modified: 2013-05-24
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)
0
Comment
Question by:DColin
3 Comments
 
LVL 20

Accepted Solution

by:
dsacker earned 300 total points
ID: 39195355
SELECT CustomerName FROM tblCustomers
WHERE ID = (SELECT MAX(ID) FROM tblCustomers)
0
 
LVL 12

Assisted Solution

by:pdebaets
pdebaets earned 200 total points
ID: 39195356
Try this

Select CustomerName from tblCustomers where ID in (Select Max([ID]) from tblCustomers);
0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 39195381
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.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now