本文介绍了选择sql查询问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我希望你能帮助我。 我正在尝试使用3个表生成一个报告 - sttakehm,sttakedm和stquem。 我写下面的查询,但它给出了unit_cost的所有值,我只需要与stquem.sequence_number = sttakedm.queue_reference和调整量匹配的单位成本。 关键是序列号在一行中,Kind =" C"和调整量在第二行,Kind =B。 我需要这个非常紧急,希望你能帮助我 SELECT sttakedm.card_number,sttakedm.product_code,sttakedm.adjustment_quantit,sttakedm.expected_quantity,sttakehm.warehouse,stquem.unit_cost,sttakehm.description1 FROM scheme.sttakedm sttakedm INNER JOIN scheme.sttakehm on sttakehm.card_number = sttakedm.card_number LEFT OUTER JOIN scheme.stquem on sttakehm.warehouse = stquem.warehouse WHERE sttakehm.card_number = sttakedm.card_number AND sttakedm.card_number =''C03323''AND(stquem.sequence_number = sttakedm.queue_reference OR(sttakedm.kind =''B''或sttakedm.kind =''C'') )和sttakedm.product_code = stquem.prod_code和sttakehm.warehouse = stquem.warehouseI hope you can help me.I am trying to generate a report using 3 tables - sttakehm, sttakedm and stquem.I wrote below query but it is giving all values of unit_cost, I only need the unit cost which matches stquem.sequence_number=sttakedm.queue_reference and adjustment quantit.The key is sequence number is in one line with Kind = "C" and adjustment quanity is on second line with Kind = "B".I need this pretty urgent, I hope you can help meSELECT sttakedm.card_number, sttakedm.product_code, sttakedm.adjustment_quantit, sttakedm.expected_quantity, sttakehm.warehouse, stquem.unit_cost, sttakehm.description1FROM scheme.sttakedm sttakedmINNER JOIN scheme.sttakehm on sttakehm.card_number = sttakedm.card_numberLEFT OUTER JOIN scheme.stquem on sttakehm.warehouse=stquem.warehouseWHERE sttakehm.card_number = sttakedm.card_number AND sttakedm.card_number=''C03323'' AND (stquem.sequence_number=sttakedm.queue_reference OR (sttakedm.kind = ''B'' OR sttakedm.kind = ''C'')) AND sttakedm.product_code = stquem.prod_code AND sttakehm.warehouse=stquem.warehouse推荐答案 这篇关于选择sql查询问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 06-20 23:35