Hello all,

Using the "items_ordered" table in the tutorial on this site, here is my question:

Let's say that I would like to extract the month and year of all the order dates. Then, group all the month/year combo's together. Now, if the quantity for each row of each month is not greater than 1, then count the number or rows for that month and year in a new column. If any of the rows quantity is greater than 1, then count the number of rows minus that row in a new column.

Example:

order_date quantity Row Total
----------- -------- ---------
30-Jun-1999 1 2
30-Jun-1999 1

01-Jul-1999 1 3
01-Jul-1999 4
06-Jul-1999 1
27-Jul-1999 1

For the month of June in 1999, the row total is 2 since no quantity is greater than 1. However, for July of 1999, the row total is 3, instead of 4... since one of the row's quantity is greater than 1. So, that row is subtracted from the total rows of that month. Can anyone help? Thanks.