select * from (SELECT titleid,count(titleid) c FROM [DragonGuoShi].[dbo].[ArticleInfo] group by titleid,[CategoryCode] having count(titleid)>1)as t order by c delete [DragonGuoShi].[dbo].[ArticleInfo] where ID not in ( SELECT max(ID) c FROM [DragonGu…
ORACLE根据账号查询每张表数据量: select t.table_name,t.num_rows from user_tables t ORDER BY NUM_ROWS DESC; SQL SERVER查询总数据量: SELECT SUM(记录条数) AS 总记录数 FROM (SELECT TOP (10000) a.name AS 表名, MAX(b.rows) AS 记录条数 FROM sys.sysobjects AS a INNER JOIN sys.sysindexes AS…
SELECT * FROM tab_init WHERE id IN ( --根据Data分类获取数据最小ID列表 select max(id) from tab_init group by a,b ) 先找出重复数据的 最大的Id ( group by 后面可跟多列, 根据规则找到重复数据), 取出 id 最大或最小的 Id, 然后使用 in查询,就可以得到不重复的数据…
SELECT * FROM rsl a, (SELECT CODE, max(time_key) time_key FROM rsl GROUP BY CODE ) b WHERE a. CODE = b. CODE AND a.time_key = b.time_key AND a. CODE IN ('HK.00700', 'HK.03888'); table :rsl 然后查询出根据每一种的code 中最新的一组数据…
一 表 内数据存的是 ‘2017-09-08 15:13:59’这样格式 表 customer_mate_follow 时间字段 created_at 1, SELECT ,) as day, COUNT(created_at) as num FROM `customer_mate_follow` GROUP BY ,) ORDER BY created_at asc; 一 表 内 插入数据存的是时间戳 $now=strtotime(date('Y-m-d')); SELECT * FRO…