Consulting

Results 1 to 1 of 1

Thread: Counting combinations using criteria from subquery

  1. #1
    VBAX Newbie
    Joined
    Jun 2012
    Posts
    1
    Location

    Question Counting combinations using criteria from subquery

    Hi, I'm new to SQL server 2008 and while I can run basic queries this has me stumped so would appreciate help.

    I have one table - Sales and I want to firstly find all clients who had more than one transaction in a day within a certain period (each transaction is a new row in the table) and then count the number of times each combination of purchases was made by those clients. These clients may also have other purchases in that month but on a different day but I do not want to count them, I'm only counting purchases that are done by those clients on the day when they make multiple transactions. I can get a subquery to find the customer IDs for these clients and how many times they purchased on the same day but can't then use those IDs to do a count of the purchase combinations. I have attached a small example of the type of table of purchases for Feb. I want to look only at the range 1st-11th Feb not the full month. The rows I hope to select is in red and the second table below it is the outcome of the query in the form I would like.

    thanks for any help, oldmonk
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •