日期:2014-05-18 浏览次数:20545 次
select count(*) as iterance_count from ( SELECT DBVIEW_artru_ZD.ARTRUID, DBVIEW_artru_ZD.CompanyCode, DBVIEW_artru_ZD.PublishDate, DBVIEW_artru_ZD.ARTRUStyle, DBVIEW_artru_ZD.ARTRUItem, DBVIEW_artru_ZD.Currency, DBVIEW_artru_ZD.ARTRU1, DBVIEW_artru_ZD.ARTRU2, DBVIEW_artru_ZD.ARTRU3, DBVIEW_artru_ZD.ARTRU4, DBVIEW_artru_ZD.ARTRU5, DBVIEW_artru_ZD.ARTRU6, DBVIEW_artru_ZD.ARTRU7, DBVIEW_artru_ZD.ARTRU8, DBVIEW_artru_ZD.ARTRU9, DBVIEW_artru_ZD.ARTRU10, DBVIEW_artru_ZD.ARTRU11, DBVIEW_artru_ZD.ARTRU12, DBVIEW_artru_ZD.ARTRU13, DBVIEW_artru_ZD.ARTRU14, DBVIEW_artru_ZD.ARTRU15, DBVIEW_artru_ZD.ARTRU16, DBVIEW_artru_ZD.ARTRU17, DBVIEW_artru_ZD.ARTRU18, DBVIEW_artru_ZD.ARTRU19, DBVIEW_artru_ZD.ARTRU20, DBVIEW_artru_ZD.ARTRU21, DBVIEW_artru_ZD.ARTRU22, DBVIEW_artru_ZD.ARTRU23, DBVIEW_artru_ZD.ARTRU24, DBVIEW_artru_ZD.ARTRU25, DBVIEW_artru_ZD.ARTRU26, DBVIEW_artru_ZD.ARTRU27, DBVIEW_artru_ZD.ARTRU28, DBVIEW_artru_ZD.ARTRU29, DBVIEW_artru_ZD.ARTRU30, DBVIEW_artru_ZD.ARTRU31,DBVIEW_artru_ZD.GUID AS _GUID_DBVIEW_artru_ZD FROM DBVIEW_artru_ZD DBVIEW_artru_ZD )YM --独立子查询,从这个表中 group by ARTRUID having count(*)>1 --根据ARTRUID分组,取出分组后count(1)> 1 的集合
------解决方案--------------------
--一个统计查询语句,统计记录数: select count(*) as iterance_count from( --从一个子查询来统计 SELECT DBVIEW_artru_ZD.ARTRUID, DBVIEW_artru_ZD.CompanyCode, DBVIEW_artru_ZD.PublishDate, DBVIEW_artru_ZD.ARTRUStyle, DBVIEW_artru_ZD.ARTRUItem, DBVIEW_artru_ZD.Currency, DBVIEW_artru_ZD.ARTRU1, DBVIEW_artru_ZD.ARTRU2, DBVIEW_artru_ZD.ARTRU3, DBVIEW_artru_ZD.ARTRU4, DBVIEW_artru_ZD.ARTRU5, DBVIEW_artru_ZD.ARTRU6, DBVIEW_artru_ZD.ARTRU7, DBVIEW_artru_ZD.ARTRU8, DBVIEW_artru_ZD.ARTRU9, DBVIEW_artru_ZD.ARTRU10, DBVIEW_artru_ZD.ARTRU11, DBVIEW_artru_ZD.ARTRU12, DBVIEW_artru_ZD.ARTRU13, DBVIEW_artru_ZD.ARTRU14, DBVIEW_artru_ZD.ARTRU15, DBVIEW_artru_ZD.ARTRU16, DBVIEW_artru_ZD.ARTRU17, DBVIEW_artru_ZD.ARTRU18, DBVIEW_artru_ZD.ARTRU19, DBVIEW_artru_ZD.ARTRU20, DBVIEW_artru_ZD.ARTRU21, DBVIEW_artru_ZD.ARTRU22, DBVIEW_artru_ZD.ARTRU23, DBVIEW_artru_ZD.ARTRU24, DBVIEW_artru_ZD.ARTRU25, DBVIEW_artru_ZD.ARTRU26, DBVIEW_artru_ZD.ARTRU27, DBVIEW_artru_ZD.ARTRU28, DBVIEW_artru_ZD.ARTRU29, DBVIEW_artru_ZD.ARTRU30, DBVIEW_artru_ZD.ARTRU31,DBVIEW_artru_ZD.GUID AS _GUID_DBVIEW_artru_ZD FROM DBVIEW_artru_ZD DBVIEW_artru_ZD --上面一个子查询,用了一大堆另外,其实,由于只是从一个表中查的,完全可以把除 from 后面的那个 DBVIEW_artru_ZD 保留外, --其他DBVIEW_artru_ZD及其后面的.号全去除.即,它等价于: /* SELECT ARTRUID, CompanyCode, PublishDate, ARTRUStyle, ARTRUItem, Currency, ARTRU1, ARTRU2, ARTRU3, ARTRU4, ARTRU5, ARTRU6, ARTRU7, ARTRU8, ARTRU9, ARTRU10, ARTRU11, ARTRU12, ARTRU13, ARTRU14, ARTRU15, ARTRU16,