Solved

need select with count

Posted on 2007-03-31
2
168 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 143

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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently, when I was asked to create a new SQL 2005 cluster, Microsoft released a new service pack for MS SQL 2005 what is Service Pack 3. When I finished the installation of MS SQL 2005 I found myself troubled why the installation of SP3 failed …
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

717 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