我想加入3个没有重复的表 [英] I want to joing 3 tables without duplicates

查看:78
本文介绍了我想加入3个没有重复的表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有三个想加入他们的名字相同,但问题是他们显示重复请帮助







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'





我尝试过:



结果:图片结果

推荐答案

这将取决于您的数据,以及它所包含的内容 - 以及您正在尝试使用它的确切内容!你的输出图像并没有告诉我们多少。



我不认为DISTINCT做你认为它做的事情: SQL SELECT DISTINCT语句 [ ^ ]

它不会将您限制为只是不同的日期值,它适用于整行 - 并且由于您的输出显示了右侧列中的差异,因此行确实是不同的。



想想你想要做什么:并尝试与样本输入和输出数据一起解释 - 请不要图像!复制并粘贴您的数据,这样如果我们需要尝试查询,我们可以通过它而不必全部输入...
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 ...


您可以使用group by删除重复项。

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


这篇关于我想加入3个没有重复的表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆