If the line items are in the same table as the customer, customer order no, etc, then your database is not normalized and unless you normalize it, you are going to run into more difficulties down the road. The Norwind sample database shows you a normalized database for customers, orders, and orderdetail.
In any case, this might work for you
SELECT Customer, Count(Orders) as TotalOrders
FROM Table1
GROUP BY Customer, Orders
ORDER BY Count(Orders) as TotalOrders DESC
John
--
John V. Ruff The Eternal Optimist :-)
Commit to the Lord whatever you do,
and your plans will succeed. Proverbs 16:3
John V. Ruff The Eternal Optimist :-)
Commit to the Lord whatever you do,
and your plans will succeed. Proverbs 16:3
-------------- Original message --------------
From: "drhovasse" <[EMAIL PROTECTED]>
See that is where the difficulty lies. For every line item that is
ordered on the same order the customer name, customer number, sales
order number and purchase order are repeated. Some orders have a
100 or more line items on it.
Thank you for your help
--- In AccessDevelopers@yahoogroups.com, "Lava Boggavarapu"
<[EMAIL PROTECTED]> wrote:
>
> Try (something like the below sql)
>
>
>
> SELECT Customer, Count(0)
>
> FROM table1
>
> GROUP BY Customer
>
> ORDER BY Count(0) DESC
>
>
>
> -----Original Message-----
> From: AccessDevelopers@yahoogroups.com
> [mailto:[EMAIL PROTECTED] On Behalf Of drhovasse
> Sent: Thursday, January 19, 2006 11:27 AM
> To: AccessDevelopers@yahoogroups.com
> Subject: [AccessDevelopers] Query database
>
>
>
> I have a database that has all orders placed for the fiscal year.
I
> am trying to run a query that will give me the customers that have
> placed the most orders for the year back. Is there away to do
that
> without knowing the customer name?
>
>
>
>
>
>
> Please zip all files prior to uploading to Files section.
>
>
>
>
> ________________________________
>
> YAHOO! GROUPS LINKS
>
>
>
> * Visit your group "AccessDevelopers
> <http://groups.yahoo.com/group/AccessDevelopers> " on the web.
>
>
> * To unsubscribe from this group, send an email to:
> [EMAIL PROTECTED]
> <mailto:[EMAIL PROTECTED]
subject=Unsubscribe
> >
>
>
> * Your use of Yahoo! Groups is subject to the Yahoo!
Terms of
> Service <http://docs.yahoo.com/info/terms/> .
>
>
>
> ________________________________
>
>
>
> The information contained in this message and any attachments
(the "Message") is intended for specific individual(s), and may be
confidential or proprietary. If you are not the intended recipient,
please notify the sender immediately, delete this Message and do not
disclose. Messages are not secure or error free and can contain
viruses and the sender is not liable for any of these occurrences.
The sender reserves the right to monitor, record and retain Messages.
>
Please zip all files prior to uploading to Files section.
YAHOO! GROUPS LINKS
- Visit your group "AccessDevelopers" on the web.
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.