如何使用查询从两个相同的结构化表中获取不同的数据 [英] How to Get Distinct Data from Two Same Structured Table using Query

查看:62
本文介绍了如何使用查询从两个相同的结构化表中获取不同的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在尝试获取数据使用以下查询但它没有给我想要的结果..



Hi
I am trying to get data Using Following Query but its not giving me desired result..

Set RSL = Nothing
If RSL.State = 1 Then RSL.Close
If Option2.Value = True Then
RSL.Open "Select BDD.BiltyNo, BDD.Article as Art, BDD.Consignee, BDD.Desti as Destination,  " & _
"BDD.Weight, BDD.Total AS Basic, (CASE WHEN BDD.Pymt_mode = 'TOPAY' THEN BDD.Total ELSE 0 END) as Topay,  " & _
"(CASE WHEN BDD.Pymt_mode = 'PAID' THEN BDD.Total ELSE 0 END) as Paid, " & _
"(CASE WHEN BDD.Pymt_mode = 'TBB' THEN BDD.Total ELSE 0 END) as TBB, BDD.pf as PF_Amt  " & _
"FROM Bilty_Detail_DELV as BDD, B_Detail_DELV_Crosing AS BDC  " & _
"WHERE BDD.BiltyNo <> BDC.BiltyNo AND BDD.Tmp_Weight = " & Text1(0).Text & " group by BDD.BiltyNo, BDD.Article, BDD.Consignee, BDD.Desti, BDD.Weight, BDD.Total, BDD.Pymt_mode, BDD.pf, BDD.Tmp_Weight", Con_Main, adOpenKeyset, adLockOptimistic





一些相同记录两个表都存在。



我不想要在Tmp_Weight = 1下B_Detail_DELV_Crosing中存在的数据



请帮助..



Some of Same records are exist in both table.

and i don''t want that data which are exist in B_Detail_DELV_Crosing under Tmp_Weight = 1

Please Help..

推荐答案

我不知道什么是 RSL ,但是在第一行中你设置为 RSL = Nothing 。下一条指令被忽略。



I don''t know what is RSL, but in the first line you set to RSL=Nothing. Next instructions are "ignored".

Set RSL = Nothing
If RSL.State = 1 Then RSL.Close
If Option2.Value = True Then


我已经解决了这个问题。 :-)



提交解决方案以备将来参考。



感谢您的帮助。 :-)





I have solved this my self. :-)

Submitting solution for future reference.

Thanks for Helping me. :-)


RSL.Open "Select Distinct(BDD.BiltyNo), BDD.Article as Art, BDD.Consignee, BDD.Desti as Destination,  " & _
"BDD.Weight, BDD.Total AS Basic, (CASE WHEN BDD.Pymt_mode = 'TOPAY' THEN BDD.Total ELSE 0 END) as Topay,  " & _
"(CASE WHEN BDD.Pymt_mode = 'PAID' THEN BDD.Total ELSE 0 END) as Paid, " & _
"(CASE WHEN BDD.Pymt_mode = 'TBB' THEN BDD.Total ELSE 0 END) as TBB, BDD.pf as PF_Amt  " & _
"FROM Bilty_Detail_DELV as BDD " & _
"WHERE BDD.BiltyNo NOT IN (SELECT DISTINCT(BDC.BiltyNo) FROM B_Detail_DELV_Crosing AS BDC) " & _
" AND BDD.Tmp_Weight = " & Text1(0).Text & _
" group by BDD.BiltyNo, BDD.Article, BDD.Consignee, BDD.Desti, BDD.Weight, BDD.Total,  " & _
" BDD.Pymt_mode, BDD.pf, BDD.Tmp_Weight", Con_Main, adOpenKeyset, adLockOptimistic


这篇关于如何使用查询从两个相同的结构化表中获取不同的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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