易截截图软件、单文件、免安装、纯绿色、仅160KB

几道经典的SQL笔试题目

几道经典的SQL笔试题目(有答案)
(1)表名:购物信息
购物人      商品名称     数量
A            甲          2
B            乙          4
C            丙          1
A            丁          2
B            丙          5
……
(其他用户实验的记录大家可自行插入)
给出所有购入商品为两种或两种以上的购物人记录
答:select * from 购物信息 where 购物人 in (select 购物人 from 购物信息 group by 购物人 having count(*) >= 2);
(2)表名:成绩表
姓名   课程       分数
张三     语文       81
张三     数学       75
李四     语文       56
李四     数学       90
王五     语文       81
王五     数学       100
王五     英语       49
……
(其他用户实验的记录大家可自行插入)
给出成绩全部合格的学生信息(包含姓名、课程、分数),注:分数在60以上评为合格
答:select * from 成绩表 where 姓名 not in (select distinct 姓名 from 成绩表 where 分数 < 60)
或者:
select * from 成绩表 where 姓名 in (select 姓名 from 成绩表 group by 姓名 having min(分数) >=60)
(3)表名:商品表
名称   产地             进价
苹果   烟台                2.5
苹果   云南                1.9
苹果   四川     


相关文档:

c# SQL数据库远程连接及配置方法

首先配置SQLSERVER2005:
打开”Microsoft SQL Server Management Studio“ 直接用Windows 用户连接进入,再在“安全性”中的“登录名”内的“新建登录名”,你就对应的添好“确定”就可以了。  
再在你对应的“数据库”里“安全性” ......

hibernate 打印SQL语句到控制台

只需要在配置文件里         hibernate.show_sql=true
    <property name="hibernateProperties">
      <value>
        hibernate.dialect=org.hibernate.dialect.Oracle9Dialect ......

防止sql注入 适用于 URL ID 纯数字

例子:  int id = Convert.ToInt32(replace((Request.QueryString["id"]), ""));
    public static string replace(string str, string str2)
    {
        str = str.Replace(";", str2);
        str = ......

调用SQL函数来实现汉字模糊查询

在sql中创建用户自定义拼音函数:
create function f_GetPy(@Str nvarchar(400))
returns nvarchar(4000)
as
begin
declare @strlen int,@re nvarchar(4000)
declare @t table(chr nchar(1) collate Chinese_PRC_CI_AS,letter nchar(1))
insert @t select '吖','A' union all select '八','B'
union all select '嚓 ......

Sql Server 查询sql执行各个阶段的时间

Sql Server 查询sql执行各个阶段的时间
set statistics io on
set statistics time on
set statistics profile on
go
[你的sql语句]
go
set statistics io off
set statistics time off
set statistics profile off

我运行:
set statistics io on
set statistics time on
set statistics profile on ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号