select total_user from a_user_no where date_time=(select max(date_time) from a_user_no where '2013-05'+ "'=to_char(date_time,'yyyy-mm')); 通过max 函数来去5月份出现最大日期的数据 查询一个月最后一天的总用户数,数据库中没有保存最好一天的数据,就查询本月数据库已存有的最后一天的数据,布布扣,bubuko.com
查询数据库中所有表名select table_name from information_schema.tables where table_schema='csdb' and table_type='base table'; 查询指定数据库中指定表的所有字段名column_nameselect column_name from information_schema.columns where table_schema='csdb' and table_name='users'
select * from [DataBase].[dbo].[TableName] where [字段一] in (select [字段一] from [DataBase].[dbo].[TableName] group by [字段一] having count([字段一]) > 1) 1.查找表中多余的重复记录,重复记录是根据单个字段(peopleId)来判断 select * from people where peopleId in (select peopleId from peop
用户表:select count(*) 总表数 from sysobjects where xtype='u' 刚才那个是用户表,下面这个是系统表加用户表: select count(*) 总表数 from sysobject s where xtype in('u','s') 总视图数:select count(*) 总视图数 from sysobjects where xtype='v' 总存储过程数:select count(*) 总存储过程数 from sysobjects where
查询数据库中某一列有没有重复数据项: select * from cd_stock where stock_bh in (select stock_bh from cd_stock group by stock_bh having count(stock_bh) >1 ) select * from cd_stock_item where id in (select id from cd_stock_item group by id having count(id) >1 ) 原文地址:htt
查询数据库中所有表名select table_name from information_schema.tables where table_schema='csdb' and table_type='base table'; 查询指定数据库中指定表的所有字段名column_nameselect column_name from information_schema.columns where table_schema='csdb' and table_name='users' 原文地址:htt
——直接放在需要查询的库中执行即可. SELECT (case when a.colorder=1 then d.name else null end) 表名, a.colorder 字段序号,a.name 字段名, (case when COLUMNPROPERTY( a.id,a.name,'IsIdentity')=1 then '√'else '' end) 标识, (case when (SELECT count(*) FROM sysobjects WHERE (name in (S