DEV Community

Cover image for How to prevent duplicate count value for inner join
Ferhat Karataş
Ferhat Karataş

Posted on • Edited on

3 2

How to prevent duplicate count value for inner join

When you join two tables and you want to count only the first table, you can use the distinct command.

select a.OrderID, count(distinct a.Id) as Total from tblOrder a 
inner join tblOrderDetail b on a.OrderID = b.OrderID
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

Image of Datadog

The Future of AI, LLMs, and Observability on Google Cloud

Datadog sat down with Google’s Director of AI to discuss the current and future states of AI, ML, and LLMs on Google Cloud. Discover 7 key insights for technical leaders, covering everything from upskilling teams to observability best practices

Learn More