new to access

T

trinity13

SELECT MonthName(Month(orders!date),1) AS [Month], Day([date]) AS
[Day], Count(orders.id) AS Countid, Sum(orders.amount) AS Sumamt
FROM orders
WHERE (((orders.paystatus)=1) AND ((orders.amount)>0))
GROUP BY MonthName(Month(orders!date),1), Day([date]),
Year(orders!date), Month(orders!date)
HAVING (((Year([orders]![date]))>2004))
ORDER BY Year(orders!date) DESC , Month(orders!date) DESC ,
MonthName(Month(orders!date),1) DESC , Day([date]) DESC;

What does the (Month(order!date),1) do exactly? and Day(now()) do?
and from what i understand
the query selects the order count, amount total, (no of ids???) , the
money each day, the price for each ad,
i am lost!!!
 
B

Baz

trinity13 said:
SELECT MonthName(Month(orders!date),1) AS [Month], Day([date]) AS
[Day], Count(orders.id) AS Countid, Sum(orders.amount) AS Sumamt
FROM orders
WHERE (((orders.paystatus)=1) AND ((orders.amount)>0))
GROUP BY MonthName(Month(orders!date),1), Day([date]),
Year(orders!date), Month(orders!date)
HAVING (((Year([orders]![date]))>2004))
ORDER BY Year(orders!date) DESC , Month(orders!date) DESC ,
MonthName(Month(orders!date),1) DESC , Day([date]) DESC;

What does the (Month(order!date),1) do exactly? and Day(now()) do?
and from what i understand
the query selects the order count, amount total, (no of ids???) , the
money each day, the price for each ad,
i am lost!!!

Month(orders!date) returns the month number (1-12) from a field called
"date" in a table called "orders".

MonthName(Month(orders!date),1) returns the name of that month, with the "1"
indicating that it should be abbreviated.

As far as I can see, Day(now()) doesn't appear anywhere in this query, but
if it did it would return the day number (1-31) from today's date.
Day([Date]) returns the day number from the field called "date" in the
orders table.

Basically the query returns a count of the records in the orders table, and
a total value for those orders, by day and month.

It's pretty sloppy stuff, though. Although orders!date works, it's poor
practice and should be orders.date (as you can see elsewhere in the query).
Also, "date" is a terrible name for a field, a real recipe for confusion.
It should be, I imagine, "order_date".
 
C

Chaim

(Month(order!date),1) is the argument list for the MonthName() function. The
Month(order!date) argument extracts the month part of a datetime field. The
'1' tells MonthName to use the abbreviation for the month name (Jan vs
January).

Day() extracts the number of the day in the month for its datetime argument.
So for the argument now(), which returns the current date and time, if you
asked Day(Now()) on '9/27/2005 10:25:15 AM', you would get '27' as the Day
value.

The query, as I read it, seems to count the number of orders and determine
the total for those orders for each date after 01 Jan 2004, counting only
those orders with a paystatus of 1 and an amount greater than 0. It then
presents this list by date from most recent to earliest.

I would question the use of the MonthName expression in the ORDER BY clause.
It already sorts by Month as a number, which makes some sense. Sorting by
month name doesn't seem to ever make sense if you want to see the months in
order.

There also seems to be some other stuff that is unneeded/redundant/clutter,
but I don't know what the goal of this query really is or how it's going to
be used.

Good Luck!
 
T

trinity13

Thanks a lot guys.. that really helped:)
I eventually hv to get everythign workign in .net. so going thru the
old database version.
 

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