Jump to content

Grouping results based on internal?


neilmunn

Recommended Posts

I have in a database which stores insurance quote requests.

I want 2 queries that count the number of quotes by each referrer, grouping quotes made within a 10 minute period as 1 quote

Here is an example of the table and the wanted results.
TABLE
ID referrer type time ip
1 XADW0124 MC 1161683434 82.7.164.59
2 XADW0124 MC 1161683464 82.7.164.59
3 XADW0124 MC 1161683484 82.7.164.59
4 XADW0124 PC 1161684425 62.173.110.62
5 XADW0139 MC 1161685322 195.137.84.105

RESULT
ID  referrer      type  time            ip
3    XADW0124  MC    1161683484  82.7.164.59
4    XADW0124  PC    1161684425  62.173.110.62
5    XADW0139  MC    1161685322  195.137.84.105

AND
Referrer        Num Quotes Filtered      Num Quotes Unfiltered
XADW0124    2                                4
XADW0139    1                                1

Thanks for the help,
Neil
Link to comment
Share on other sites

Intersting question... if it were by day/month, this would be relatively easy, since you could either use a sub-query or use a derived table; however, I'm stumped on how to generate 10-minute period bins... maybe with a self-join?  I'll have to think about it.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.