Solved

need select with count

Posted on 2007-03-31
2
159 Views
Last Modified: 2010-08-05
I have a query:
Select Distinct email, quote, product, DATE From tblTest
that generates the following type of data...
a_s@company.org      102297      prod1            2/26/2007
a_k@company.org      60448      prod2      2/8/2007
a_k@company.org      72454      prod2      2/8/2007
a_k@company.org      133024      prod2      3/19/2007
a_k@company.org      133030      prod2      3/19/2007
a_k@company.org      134622      prod2      3/20/2007
a_k@company.org      134936      prod2      3/20/2007
a_k@company.org      134981      prod2      3/20/2007
a_l@company.org      987610      prod2      2/16/2007
a_l@company.org      84018      prod1            2/9/2007
a_l@company.org      85573      prod2      2/13/2007
A_T@company.org      32334      prod2      1/14/2007
A_T@company.org      88763      prod2      3/13/2007
A_T@company.org      123372      prod2      3/22/2007
a_c@company.org      62272      prod1            1/23/2007
a_c@company.org      84560      prod3      2/9/2007
a_c@company.org      100968      prod1            2/23/2007
a_c@company.org      135166      prod3      3/20/2007
A_L@company.org      105942      prod4      2/28/2007
a_j@company.org      37878      prod2      12/28/2006

How can I get the count of distinct quotes,product,date per email in the same table? I know how to get it in a different table with email and count...
but something like this:
a_s@company.org      102297      prod1            2/26/2007      1
a_k@company.org      60448      prod2      2/8/2007      7
a_k@company.org      72454      prod2      2/8/2007      7
a_k@company.org      133024      prod2      3/19/2007      7
a_k@company.org      133030      prod2      3/19/2007      7
a_k@company.org      134622      prod2      3/20/2007      7
a_k@company.org      134936      prod2      3/20/2007      7
a_k@company.org      134981      prod2      3/20/2007      7
a_l@company.org      987610      prod2      2/16/2007      3
a_l@company.org      84018      prod1            2/9/2007      3
a_l@company.org      85573      prod2      2/13/2007      3
A_T@company.org      32334      prod2      1/14/2007      3
A_T@company.org      88763      prod2      3/13/2007      3
A_T@company.org      123372      prod2      3/22/2007      3
a_c@company.org      62272      prod1            1/23/2007      4
a_c@company.org      84560      prod3      2/9/2007      4
a_c@company.org      100968      prod1           2/23/2007      4
a_c@company.org      135166      prod3      3/20/2007      4
A_L@company.org      105942      prod4      2/28/2007      1
a_j@company.org      37878      prod2      12/28/2006      1

Is it possible even?


0
Comment
Question by:acdagirl
2 Comments
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 18829084
select t.*, ( select count(*) from tblTest i where i.email = t.email )
from tblTest t
0
 

Author Comment

by:acdagirl
ID: 18829121
I modified to to give me the fields of interest as my tblTest contains more fields, etc. that might skew the whole "distinct" thing I was looking for versus the t.* idea... I got what I needed. thanks!
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

This article will describe one method to parse a delimited string into a table of data.   Why would I do that you ask?  Let's say that you need to pass multiple parameters into a stored procedure to search for.  For our sake, we'll say that we wa…
So every once in a while at work I am asked to export data from one table and insert it into another on a different server.  I hate doing this.  There's so many different tables and data types.  Some column data needs quoted and some doesn't.  What …
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now