We help IT Professionals succeed at work.
Get Started

Help with MS SQL query on duplicates

Last Modified: 2019-11-21
excuse the (probably) newbie question.
I must discover the "duplicates" in a list of books (where "duplicates" means books of same title and same location).
I've created the following query based on the items table of the database:

SELECT [bookId]
	  , COUNT(*)
  FROM [database].[dbo].[items]
    [bookId], [locationId]
    COUNT(*) > 1

Open in new window

it works well, but the info about the books is completed by other 2 tables:

1) [database].[dbo].[books]
that has [Id] = [database].[dbo].[items].[bookId]

2) [database].[dbo].[locations]
that has [Id] = [database].[dbo].[items].[locationId]

these tables contains other useful info that I want to include in my previous query, like:
is it possible doing so?
Thanks a lot,
Watch Question
SQL Server DBA & Architect, EE Solution Guide
Awarded 2009
Distinguished Expert 2019
This problem has been solved!
Unlock 2 Answers and 3 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant

An Experts Exchange subscription includes unlimited access to online courses.

Get Started
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE