Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6003205
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:05:19+00:00 2026-05-23T01:05:19+00:00

I have a table like the one below. It is a record of daily

  • 0

I have a table like the one below. It is a record of daily featured products and the customers that purchased them (similar to a daily deal site). A given client can only purchase a product one time per feature, but they may purchase the same product if it is featured multiple times.

FeatureID | ClientID | FeatureDate | ProductID  
 1           1002      2011-05-01      500  
 1           2333      2011-05-01      500  
 1           4458      2011-05-01      500  
 2           8888      2011-05-10      700  
 2           2333      2011-05-10      700  
 2           1111      2011-05-10      700    
 3           1002      2011-05-20      500  
 3           4444      2011-05-20      500  
 4           4444      2011-05-30      500  
 4           2333      2011-05-30      500  
 4           1002      2011-05-30      500   

I want to count by FeatureID the number of clients that purchased FeatureID X AND who purchased the same productID during a previous feature.

For the table above the expected result would be:

FeatureID | CountofReturningClients  
 1          0  
 2          0  
 3          1  
 4          3

Ideally I would like to do this with SQL, but am also open to doing some manipulation in Excel/PowerPivot. Thanks!!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T01:05:20+00:00Added an answer on May 23, 2026 at 1:05 am

    If you join your table to itself, you can find the data you’re looking for. Be careful, because this query can take a long time if the table has a lot of data and is not indexed well.

    SELECT t_current.FEATUREID, COUNT(DISTINCT t_prior.CLIENTID)
    FROM table_name t_current
    LEFT JOIN table_name t_prior
    ON t_current.FEATUREDATE > t_prior.FEATUREDATE
    AND t_current.CLIENTID = t_prior.CLIENTID
    AND t_current.PRODUCTID = t_prior.PRODUCTID
    GROUP BY t_current.FEATUREID
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a database table that has a structure like the one shown below:
I have a table like below <table> <tr> <td>Item1</td><td>Price-100</td><td>1</td><td><input type=button value=add one/> </tr> <tr>
i have table called table1 and it looks like the below record type tran_ref_number
I have a Table like this one: |UserId | ContactID | ContactName --------------------------------------- |
i have a table like this one: -------------------------------- id | name -------------------------------- 1 |
I have a table like this one: id group value 1 GROUP A 0.641028
I have a data.table object like this one library(data.table) a <- structure(list(PERMNO = c(10006L,
I have a table which looks like this one: | id | fk_book |
I have a table and I'd like to pull one row per id with
I have a table and one of the columns holds web addresses like: 'http://...'

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.