我被赋予了从Oracle数据库中选择关键数据的任务,但我注意到我的select正在返回重复的行.我不需要它们用于我的报告但我不希望它们删除它们.有人可以帮助只获取我需要的数据.我尝试了以下代码,但这没有用.
SELECT distinct bbp.SUBCAR "Treadwell",bbp.BATCH_ID "Batch ID",bcs.SILICON "Si",bcs.SULPHUR "S",bcs.MANGANESE "Mn",bcs.PHOSPHORUS "P",to_char(bcs.SAMPLE_TIME,'dd-MON-yy hh24:MI') "Sample Time",to_char(bbp.START_POUR,'dd-MON-yy hh24:MI') "Start Pour Time",to_char(bbp.END_POUR,'dd-MON-yy hh24:MI') "End pour Time",bofcs.temperature "Temperature" FROM bof_chem_sample bcs,bof_batch_pour bbp,bof_celox_sample bofcs WHERE bcs.SAMPLE_CODE= to_char('D1') AND bbp.BATCH_ID=bcs.BATCH_ID AND bcs.SAMPLE_TIME>=to_date('01-jan-10')
如果查看转换为sql Server类型sql的查询,您将看到bofcs表与其余数据之间没有关系.基本上它会返回bofcs温度场中的每条记录,这可能会产生重复的结果?
原文链接:https://www.f2er.com/oracle/204863.htmlSELECT bbp.SUBCAR "Treadwell",bofcs.temperature "Temperature" FROM bof_chem_sample bcs,INNER JOIN bof_batch_pour bbp,ON bbp.BATCH_ID=bcs.BATCH_ID INNER JOIN bof_celox_sample bofcs ON **-- NO RELATION B/N BOFCS and the other tables????** WHERE bcs.SAMPLE_CODE= to_char('D1') AND bcs.SAMPLE_TIME>=to_date('01-jan-10')