Click here to Skip to main content
15,880,132 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have three and want join them where name equal to same but the problem is they show duplicates please help



select  Distinct  shopentry.[Date]
      ,shopentry.[Name]
      ,shopentry.[Mandi Rate Subha]
      ,shopentry.[Mandi Rate Total Subha]
      ,shopentry.[Bandi Rate Total]
     ,shopentry.[Mandi Rate Sham]
     ,shopentry.[Mandi Rate Total Sham]
      ,shopentry.[Total]
,shopentry.[total doodh]
	  ,shop_cash.[Cash]
      ,shopentry.[Cash], 
	  shopacc.Baqaya,
	  shopacc.Commission
	 from shopentry inner join shopacc on shopentry.Name=shopacc.Name 
	  inner join shop_cash on shop_cash.Name=shopacc.Name  where shopentry.Name='Danish' and shopentry.date between '12/11/2017' and '12/13/2017'


What I have tried:

result: Image result
Posted
Updated 28-Nov-18 22:49pm
Comments
F-ES Sitecore 29-Nov-18 5:32am    
What rows in that image do you think are duplicates? They all look unique to me?

That's going to depend on your data, and exactly what it contains - plus exactly what you are trying to do with it! And an image of your output doesn't tell us much at all.

I don't think DISTINCT does what you think it does: SQL SELECT DISTINCT Statement[^]
It doesn't limit you to "just the distinct Date values", it applies to the whole row - and since your output shows differences in the columns to the right hand side, the rows are indeed distinct.

Think about what you are trying to do: and try to explain that together with sample input and output data - and no images please! Copy and paste your data so if we need to try queries we can past it in instead of having to type it all ...
 
Share this answer
 
You can use group by to remove duplicates.
select shopentry.[Date],shopentry.[Name],shopentry.[Mandi Rate Subha],shopentry.[Mandi Rate Total Subha],shopentry.[Bandi Rate Total],shopentry.[Mandi Rate Sham]
     ,shopentry.[Mandi Rate Total Sham],shopentry.[Total],shopentry.[total doodh],shop_cash.[Cash],shopentry.[Cash],shopacc.Baqaya,shopacc.Commission
from shopentry 
	inner join shopacc on shopentry.Name=shopacc.Name 
	inner join shop_cash on shop_cash.Name=shopacc.Name  
where shopentry.Name='Danish' and shopentry.date between '12/11/2017' and '12/13/2017'
group by shopentry.[Date],shopentry.[Name],shopentry.[Mandi Rate Subha],shopentry.[Mandi Rate Total Subha],shopentry.[Bandi Rate Total],shopentry.[Mandi Rate Sham]
     ,shopentry.[Mandi Rate Total Sham],shopentry.[Total],shopentry.[total doodh],shop_cash.[Cash],shopentry.[Cash],shopacc.Baqaya,shopacc.Commission
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900