Re: Unique Values Query

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Single Query Solution;

SELECT Sales.Customer,
Sales.Item,
Sales.Price,
Sum(Sales.Quantity) AS TotalQuantity,
Sum([Price]*[Quantity]) AS TotalValue

FROM Sales

WHERE EXISTS (
SELECT ASales.Customer
FROM Sales AS ASales
WHERE ASales.Customer = Sales.Customer
AND ASales.Item = Sales.Item
AND ASales.Price <> Sales.Price
)

GROUP BY Sales.Customer, Sales.Item, Sales.Price;



"Don" <Don@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:1C45F81E-20CA-4FF8-80F4-9A7B70581F62@xxxxxxxxxxxxxxxx
> I have a table with about 125,000 records. The fields consist of Customer
> Number, Item Number and Price. Each record indicates a purchase by a
> customer. Many of the purchases are for the same item, at the same price;
> however, there are occasional price increases. Here is what I want to do.
I
> want to return every instance of customer purchases when the price is
> different. For instance, if customer 1 bought item 2 for $3.00 a total of
10
> times and then the price went to $4.00. I want the query to return 1
record
> of customer 1 buying item 2 for $3.00 and 1 record of customer 1 buying
item
> 2 for $4.00 (This I can do by selecting Unique Values in the query's
> properties. Here's the kicker - I don't want the query to return any
items
> that have only had 1 price (For instance, 1 unique value) What I'm trying
to
> do is identify every customer that have had price changes and what they
have
> been. Any help would be useful if I haven't confused you. Thanks...
> --
> Don Rountree


.



Relevant Pages

  • Re: guitar ctr vs. Sam @$$
    ... customer service skills, ... stores in the past, haven't been isolated incidents. ... at our store they don't even bother to put price ... They have these stupid-cheap sales from time to ...
    (rec.music.makers.percussion)
  • Re: Aggregate string concatenation efficiency problem
    ... Column5 -- it looks like you want to list multiple consultants ... for each customer - on the same record. ... Here is my pseudo code for your query ... search, in this case, in Sales, a VIN or Stock#, and what is returned ...
    (comp.databases.ms-access)
  • RE: Query: Combination of Group By, Top 10, Sorting...
    ... I changed the SalesHistory_SUM query ... This query totals all sales not included in the customer top 5. ...
    (microsoft.public.access.queries)
  • att: Tom Ellison: How to compare last years to todays numbers from one table?
    ... Thank you very much for your tips, took a while to get it working but here a copy of the query I managed to patch together: ... What you'd have remaining is Customer / Sales / Prev Sales. ... >Tom Ellison ...
    (microsoft.public.access.queries)
  • Re: Finding records
    ... One query method that may work: ... FROM (Customers as C INNER JOIN Sales as S ... I have three tables, one is Customer, one is Item and one is Sales. ...
    (microsoft.public.access.queries)