Select T1.Item_No, T1.VENDOR_NO, T1.PRICE
From Item as T1, Item as T2
Where T1.Item = T2.Item and T1.Price < T2.Price
可以吗?
From Item as T1, Item as T2
Where T1.Item = T2.Item and T1.Price < T2.Price
可以吗?
解决方案 »
- 谢谢帮我解决这个Gina
- 请记录Record与指针问题
- 设置了很多断点,那个快捷键是 清楚所有断点的
- 今天终于体会了一下Delphi的缺陷
- 请问哪位大哥大姐有Delphi 7的Personal Edition?
- 郁闷的菜鸟:Could not convert variant of type(null) into type(String)?
- 问题:
- 如何制作Delphi的安装包
- 谁用过popMenu?为什么设置自动弹出属性后点鼠标右键不能弹出呢?
- 如何SQL查询paradoxt中的日期字段?
- 调试的时候生成的可执行文件只能存在5秒钟,然后自动消失,怎么回事?救救我
- 100分!求XLGrid1.7源代码,提供线索也可
FROM (Select Item_No,Vendor_NO,min(Price)
group by Item_No,Vendor_No) AS a
LEFT JOIN item
ON (a.tprice=item.price) AND (a.Item_No=item.Item_No)
3:参照1,2
declare cur_Item cursor for
select itemno,min(price) from tab_1 group by itemno
然后再用 select top 1的方法,选出其中一个。
from Table A
where A.PRICE=
(SELECT MIN(B.PRICE) FROM TABLE B
WHERE A.ITEM_NO=B.ITEM_NO)
GROUP BY A.ITEM_NO,A.PRICE
没怎么简单吧
select *
from table1 a inner join (select top 1 c.item_no ,c.vendor from table1 c join (select item_no ,min(price) group by item_no
from table1) d where c.item_no = d.item_no and c.price = d.price) b
where a.item_NO = b.item_no and a.vendor = b.vendor
有些地方可能有点小问题,但这样写肯定没错
select * from (select item_no,min(vendor) as vendor from( select b.item_no,b.vendor,b.price from
(select item_no ,min(price) as minprice from table1 group by item_no) a inner join table1 b on a.item_no = b.item_no and a.minprice = b.price) x group by x.item_no) y join table1 z on y.item_no = z.item_no and y.vendor = z.vendor
*为你的表的列,必须一项项写上去。
真没想到有这么变态的sql语句。我建议你写一个view