读书人

SQL查询语句去掉重复记录解决办法

发布时间: 2012-04-16 16:20:04 作者: rapoo

SQL查询语句去掉重复记录


当字段值 ProductID,GuiGe,XingHao,SalePrice 相同时只显示一条记录

求高手解决

[解决办法]

SQL code
select * from tablename t where 主键字段=(select max(主键字段) from tablename where ProductID=t.ProductID and GuiGe=t.GuiGe and XingHao=t.XingHao and SalePrice=t.SalePrice)
[解决办法]
SQL code
--方法一:select distinct ProductID,GuiGe,XingHao,SalePrice into  temp from tb truncate table tbinsert into( ProductID,GuiGe,XingHao,SalePrice)  select  ProductID,GuiGe,XingHao,SalePrice   from temp 

读书人网 >SQL Server

热点推荐