repete Customers

N

nishkrish

I need towrite a query to find out if there are any repet customers for a
specific month

ex if a specfic customer sends the same order twice for a month
 
K

KARL DEWEY

Try this ---
SELECT nishkrish_1.Customer, Format([OrderDate],"mmmm yyyy") AS [Order],
Count(nishkrish_1.Customer) AS Orders
FROM nishkrish_1
GROUP BY nishkrish_1.Customer, Format([OrderDate],"yyyymm"),
Format([OrderDate],"mmmm yyyy")
HAVING (((Count(nishkrish_1.Customer))>1))
ORDER BY nishkrish_1.Customer, Format([OrderDate],"yyyymm");

Use your table name instead of nishkrish_1 and your field names.
 
N

nishkrish

SELECT ACTIVITY 2007.SENDER, Format([Date],"mmmm yyyy") AS [TRXN #],
Count(ACTIVITY 2007.SENDER) AS TRXN #
FROM ACTIVITY 2007
GROUP BY ACTIVITY 2007.SENDER, Format([Date],"yyyymm"),
Format([Date],"mmmm yyyy")
HAVING (((Count(ACTIVITY 2007.SENDER))>1))
ORDER BY ACTIVITY 2007.SENDER, Format([Date],"yyyymm");

i tried this but shows error Syntax error(missing operator) in query
expression ' Activity 2007.Sender'
--
Nisha P


KARL DEWEY said:
Try this ---
SELECT nishkrish_1.Customer, Format([OrderDate],"mmmm yyyy") AS [Order],
Count(nishkrish_1.Customer) AS Orders
FROM nishkrish_1
GROUP BY nishkrish_1.Customer, Format([OrderDate],"yyyymm"),
Format([OrderDate],"mmmm yyyy")
HAVING (((Count(nishkrish_1.Customer))>1))
ORDER BY nishkrish_1.Customer, Format([OrderDate],"yyyymm");

Use your table name instead of nishkrish_1 and your field names.
--
KARL DEWEY
Build a little - Test a little


nishkrish said:
I need towrite a query to find out if there are any repet customers for a
specific month

ex if a specfic customer sends the same order twice for a month
 
J

John Spencer

You have spaces in your table name and field names, so you MUST surround
each element with square brackets. Also, you cannot give two fields the
same alias (name)

SELECT [ACTIVITY 2007].SENDER
, Format([Date],"mmmm yyyy") AS [TRXN #]
, Count([ACTIVITY 2007].SENDER) AS [TRXN #2]
FROM [ACTIVITY 2007]
GROUP BY [ACTIVITY 2007].SENDER, Format([Date],"yyyymm")
HAVING Count([ACTIVITY 2007].SENDER))>1
ORDER BY [ACTIVITY 2007].SENDER, Format([Date],"yyyymm");

--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..

nishkrish said:
SELECT ACTIVITY 2007.SENDER, Format([Date],"mmmm yyyy") AS [TRXN #],
Count(ACTIVITY 2007.SENDER) AS TRXN #
FROM ACTIVITY 2007
GROUP BY ACTIVITY 2007.SENDER, Format([Date],"yyyymm"),
Format([Date],"mmmm yyyy")
HAVING (((Count(ACTIVITY 2007.SENDER))>1))
ORDER BY ACTIVITY 2007.SENDER, Format([Date],"yyyymm");

i tried this but shows error Syntax error(missing operator) in query
expression ' Activity 2007.Sender'
--
Nisha P


KARL DEWEY said:
Try this ---
SELECT nishkrish_1.Customer, Format([OrderDate],"mmmm yyyy") AS [Order],
Count(nishkrish_1.Customer) AS Orders
FROM nishkrish_1
GROUP BY nishkrish_1.Customer, Format([OrderDate],"yyyymm"),
Format([OrderDate],"mmmm yyyy")
HAVING (((Count(nishkrish_1.Customer))>1))
ORDER BY nishkrish_1.Customer, Format([OrderDate],"yyyymm");

Use your table name instead of nishkrish_1 and your field names.
--
KARL DEWEY
Build a little - Test a little


nishkrish said:
I need towrite a query to find out if there are any repet customers for
a
specific month

ex if a specfic customer sends the same order twice for a month
 
S

Steve

Consider changing the design of your tables to:
TblCustomer
CustomerID
CustomerName
<<Other customer contact fields>>

TblOrder
OrderID
OrderDate
CustomerID
<<Other order fields needed for your database>>

In your current design, you enter the customer name for each order. If there
is a misspelling of a customer name, Access will treat them as different
customers. In the above suggested orders table, you would enter the customer
by a combobox so a customer is identified exactly the same every time he
places an order.

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)




nishkrish said:
SELECT ACTIVITY 2007.SENDER, Format([Date],"mmmm yyyy") AS [TRXN #],
Count(ACTIVITY 2007.SENDER) AS TRXN #
FROM ACTIVITY 2007
GROUP BY ACTIVITY 2007.SENDER, Format([Date],"yyyymm"),
Format([Date],"mmmm yyyy")
HAVING (((Count(ACTIVITY 2007.SENDER))>1))
ORDER BY ACTIVITY 2007.SENDER, Format([Date],"yyyymm");

i tried this but shows error Syntax error(missing operator) in query
expression ' Activity 2007.Sender'
--
Nisha P


KARL DEWEY said:
Try this ---
SELECT nishkrish_1.Customer, Format([OrderDate],"mmmm yyyy") AS [Order],
Count(nishkrish_1.Customer) AS Orders
FROM nishkrish_1
GROUP BY nishkrish_1.Customer, Format([OrderDate],"yyyymm"),
Format([OrderDate],"mmmm yyyy")
HAVING (((Count(nishkrish_1.Customer))>1))
ORDER BY nishkrish_1.Customer, Format([OrderDate],"yyyymm");

Use your table name instead of nishkrish_1 and your field names.
--
KARL DEWEY
Build a little - Test a little


nishkrish said:
I need towrite a query to find out if there are any repet customers for
a
specific month

ex if a specfic customer sends the same order twice for a month
 
C

Chris2

nishkrish said:
SELECT ACTIVITY 2007.SENDER, Format([Date],"mmmm yyyy") AS [TRXN #],
Count(ACTIVITY 2007.SENDER) AS TRXN #
FROM ACTIVITY 2007
GROUP BY ACTIVITY 2007.SENDER, Format([Date],"yyyymm"),
Format([Date],"mmmm yyyy")
HAVING (((Count(ACTIVITY 2007.SENDER))>1))
ORDER BY ACTIVITY 2007.SENDER, Format([Date],"yyyymm");

i tried this but shows error Syntax error(missing operator) in query
expression ' Activity 2007.Sender'

Nisha P,

Activity 2007 has a space in it, and must have [] around it.

TRXN # also has a space in it, and the second occurrence must have [] around it.

SELECT [ACTIVITY 2007].SENDER
,Format([Date],"mmmm yyyy") AS [TRXN #]
,Count([ACTIVITY 2007].SENDER) AS [TRXN #]
FROM [ACTIVITY 2007]
GROUP BY [ACTIVITY 2007].SENDER
,Format([Date],"yyyymm")
,Format([Date],"mmmm yyyy")
HAVING Count([ACTIVITY 2007].SENDER) > 1
ORDER BY [ACTIVITY 2007].SENDER, Format([Date],"yyyymm");

The above will save successfully.

I do not know why you have two columns with the same alias.

Notes:

Do not use spaces or special characters in the names of tables, queries, reports, modules,
macros, forms, or controls.

[] just clutter code and make it less readable.


Sincerely,

Chris O.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top