引用 13 楼 acmain_chm 的回复:
SQL codeselecttop3*from t_reyoreyoreyo twhere nclassid='Bush'andnotexists (select1from t_reyoreyoreyowhere nclassid='Bush'and O_Id <t.O_Idand (opertiontime=t.opertiontimeor unitprice=t.unitprice
¡
select top 6 * from "+enttable+" t where nclassid=? and not exists ( select 1 from "+enttable+" where nclassid=? and goodsid <t.goodsid and (opertiontime=t.opertiontime or unitprice=t.unitprice) ) order by opertiontime desc
我还想显示 "+usitable+" 中的 company 字段,"+usitable+"与 "+enttable+" 通过
"+usitable+".username="+enttable+".buyform
我这样写不行
select top 6 * from "+enttable+" t where nclassid=? and not exists ( select 1 from "+enttable+","+usitable+" where "+usitable+".username="+enttable+".buyform and "+usitable+".nclassid=? and goodsid <t.goodsid and (opertiontime=t.opertiontime or unitprice=t.unitprice) ) order by opertiontime desc
望高手帮忙啊
没看懂你的需求。
建议你用些例子说明。
建议你列出你的表结构,并提供测试数据以及基于这些测试数据的所对应正确结果。
我想实现:查询指定表的("+enttable+" )的指定分类(nclassid=?)的,不同时间(opertiontime)不同价格(unitprice)的前3条记录。