Need to build an SQL query with a count and 2 tables

I have 2 tables. Table A has a column called SameIDs, Table B also has a column called SameIDs. In Table B, the SameIDs column will only have unique entries, but in table A it can have many with the same results in that column.  I need to query the results of Table B, and also create a column in my query to count the number of times the unique entry is listed in Table A. Below are sample tables and what I'd like the query to output... can someone help? Thank you!

Table A                      Table B      
SameIDs                   SameIDs           Notes           Date
     5                               5                    fake note     9/18/15
     5                               7                    test note      9/18/15
     5
     7
     7

I want the query to output this:

 SameIDs    Notes           Date            TheCount
          5     fake note     9/18/15                    3
          7     test note      9/18/15                    2
earwig75Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

MlandaTCommented:
SELECT TableB.ID, TableB.Notes, TableB.Date, COUNT(TableA.*)
FROM TableB
     INNER JOIN TableA ON TableB.ID = TableA.ID
GROUP BY TableB.ID, TableB.Notes, TableB.Date

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Scott PletcherSenior DBACommented:
SELECT b.SameIDs, b.Notes, b.Date,
    (SELECT COUNT(*) FROM TableA a WHERE a.SameIDs = b.SameIDs) AS TheCount
FROM TableB b
ORDER BY SameIDs
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.