随笔分类 -  数据库

摘要:表A中存在ID重复三次以上的记录,完整的查询语句如下:select * from(select count(ID) as count from table group by ID)T where T.count>3-表A中存在ID重复三次以上的记录,完整的查询语句如下:select * from(select count(ID) as count from table group by ID)T where T.count>3sc 按升序排列desc 按降序排列下列语句部分是Mssql语句,不可以在access中使用。SQL分类:DDL—数据定义语言(Create,Alter,Dr 阅读全文
posted @ 2013-03-01 15:12 年华° 阅读(205) 评论(0) 推荐(0)
摘要:mysql:select * from table1 where 1=1 limit 10sql server:读取前10条:select top (10) * from table1 where 1=1读取后10条:select top (10) * from table1 order by id desc在sqlserver里面,如何读取按照某个排序,第5到10这五个记录select top 6 * from table where id not in(select top 4 id from table)oracle:select * from table1 where rownum&l 阅读全文
posted @ 2013-03-01 15:05 年华° 阅读(211) 评论(0) 推荐(0)
摘要:表结构stu_id varchar2(8)stu_na varchar2(20)stu_sco numberstu_class varchar2(4)请用SQL语句完成如下查询:①,求出各班的及格率(成绩>=60)②,求出个班的优秀率(成绩>=80)相关脚本SELECT STU_CLASS,ROUND(COUNT(CASEWHEN T.STU_SCO >= 60 THEN1ELSENULLEND) * 100 / COUNT(*),2) || ‘%’FROM TEST_TU TGROUP BY STU_CLASS 阅读全文
posted @ 2013-03-01 15:00 年华° 阅读(4387) 评论(0) 推荐(0)
摘要:oracle 在手工创建一个用户后,用pl/sql查询时,出现以下错误:dynamic performance tables not accessible,automatic statistics disabled for this sessionyou can disable statistics in the preference menu,or obtain selectpriviliges on the V$session,v$sesstat and v$statname tables已经把系统权限 赋予 给这个用户了百度后,解决方法如下:grant SELECT ANY DICTIO 阅读全文
posted @ 2012-04-21 09:48 年华° 阅读(522) 评论(0) 推荐(0)
摘要:假设 有数据库A 数据库B,想要把数据库A中的表复制到数据库B中首先create public database link mydblink connect tosys identified by "123" using 'A';-------sys为对象 123是密码 create tableaa as select * from aa@mydblinkaa是A中表如果想要复制所有的表 则 select 'create table '||table_name||' as select * from'||table_name| 阅读全文
posted @ 2012-04-20 16:22 年华° 阅读(3924) 评论(1) 推荐(0)