SQL语言面试题(持续更新)

1. 找出表ppp里面num最小的数,不能使用min函数。
select * from ppp where num <=all(select num from ppp)
// or
select top 1 num from ppp order by num

2. 找出表ppp里面最小的数,可以使用Min函数。
select * from ppp where num =(select Min(num) from ppp)

3. 选择表ppp2中num重复的记录。
select * from ppp2 where num in(select num form ppp2 group by num having(count(num)>1))

4. 写出复制表、拷贝表和表联查的SQL语句。
// 复制表(只复制表结构,源表名:A,新表名:B)
select * into B from A where 1=0

// 拷贝表(拷贝数据,源表名:A,新表名:B)
select * into B from A

// 四表联查
select * from A,B,C,D where 关联条件

5. 在SQLServer中用SQL语句建立一张临时表
create table #Temp(字段1 类型,字段2 类型)
注意,临时表要在表名前面加"#"

posted on 2011-12-02 00:29 梦五 阅读(306) 评论(0)  编辑 收藏 引用 所属分类: SQL Server


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理


<2011年12月>
27282930123
45678910
11121314151617
18192021222324
25262728293031
1234567

导航

统计

常用链接

留言簿

随笔分类

随笔档案

文章分类

文章档案

搜索

最新评论

阅读排行榜

评论排行榜