ZKX's LAB

sql查询不重复数据 sql 查询数据表后 在统计某一列数据不重复的数量

2021-04-23知识6

SQL 如何查询重复的数据如下图 “以mum为基准查出姓名是一样的数据”这句话不太好理解。这里先按查出姓名有重复的记录,列出num和姓名字段并按姓名升序、num升序排序,sql语句如下:(假设表名为t1)select a.num,a.name from t1 a,(select name from t1 group by namehaving count(1)>;1)b wherea.name=b.name order bya.name,a.num;如果上述语句不是题主需要的效果,请追问。最好是列出输出效果列表,这样将有助于理解您的实际需求,以便我能我编写出满意的sql语句。

sql 查询不重复的数据 -下面是查询出有重复ID的数据,具体的删除你自己弄,因为主从表关系限制,我就不写删除语句啦,你自己看情况删除select*from product_infowhere id in(select id from product_infogroup by type_idselect id from product_info_picwhere infoid in(select id from product_infogroup by type_id)

sql 查询数据表后 在统计某一列数据不重复的数量 友善的提醒两点,如有帮助还望采纳,谢谢!第一、你这个语句本身写的有点麻烦,简化如下SELECT[Store_Abbreviation],[Goodname],[Goodmodel],SUM(Order_Quantity)AS Order_Quantity,[Workid]from[fangtaidata].[dbo].[SalesStatistics]where[Delivery_Date]between '2014-07-02' and '2014-07-25'GROUP BY[Store_Abbreviation],[Goodmodel],[Workid],[Goodname]第二、统计不重复的数量也很简单,再写个语句只取第一列select count(distinct Store_Abbreviation)from[fangtaidata].[dbo].[SalesStatistics]where[Delivery_Date]between '2014-07-02' and '2014-07-25'想得到多列的数量select count(distinct Store_Abbreviation),count(distinct Goodname),count(distinct Goodmodel),count(distinct Workid)from[fangtaidata].[dbo].[SalesStatistics]where[Delivery_Date]between '2014-07-02' and '2014-07-25'码字不易,如有帮助,还望采纳,谢谢!

随机阅读

qrcode
访问手机版