sql中比较大小

if object_id('tempdb..#dataOldNew1') is not null drop table #dataOldNew1
select
distinct store_cd
,item_cd
, ItemType
, CompStoreNM
, CompPrice
-- , CompStandardNum
-- , CompBrandNM
, CreateDate
into
#dataOldNew1
from
#alldata as a
where
(
select count(o) from #alldata as b
where
a.item_cd=b.item_cd
and
a.store_cd=b.store_Cd
and
a.CompStoreNM=b.CompStoreNM
and
a.inum<b.inum
--a.createdate<b.createdate
)<1

posted @ 2014-10-21 11:28  笑看天下  阅读(7862)  评论(0编辑  收藏  举报