追求卓越,挑战极限,在绝望中寻找希望,人生终将辉煌!

发布新日志

  • SQL查询经典例题

    2010-03-09 17:35:27

    通过以下习题的练习,我们能快速熟悉掌握sql语句查询的语法和要领,大家要用心领会其中的要领和步骤,要学会分析步骤。

    一、单表查询练习

    1、查询<学生信息表>,查询学生"张三"的全部基本信息

    Select *

    from A_studentinfo

    where sname='张三'

     

    2、查询<学生信息表>,查询学生"张三"李四的基本信息

    Select *

    from A_studentinfo

    where sname='张三'

    or sname='李四'

     

    3、查询<学生信息表>,查询姓""学生的基本信息

    Select *

    from A_studentinfo

    where sname like '%'

     

    4、查询<学生信息表>,查询姓名中含有""字的学生的基本信息

    Select *

    from A_studentinfo

    where sname like '%%'

     

    5、查询<学生信息表>,查询姓名长度为三个字,姓“李”,且最后一个字是“强”的全部学生信息。

    select *

    from A_studentinfo

    where sname like '_'

     

    6、查询<学生信息表>,查询姓""或者姓的学生的基本信息。

    Select *

    from A_studentinfo

    where sname like '%'

    or sname like '%'

     

    7、查询<学生信息表>,查询姓""并且"所属省份""北京"的学生信息

    Select *

    from A_studentinfo

    where sname like '%'

    and province='北京'

     

    8、查询<学生信息表>,查询"所属省份""北京"新疆山东或者"上海"的学生的信息

    Select *

    from A_studentinfo

    where province in ('北京','上海','新疆','山东')

     

    9、查询<学生信息表>,查询姓"",但是"所属省份"不是"北京"的学生信息

    Select *

    from A_studentinfo

    where sname like '%'

    and province !='北京'

     

    10、查询<学生信息表>,查询全部学生信息,并按照“性别”排序,性别相同的情况下按照“所属省份”排序,所属省份相同的情况下再按照“班级”排序

    select *

    from A_studentinfo

    order by sex,province,class

     

    11、查询<学生信息表>,查询现有学生都来自于哪些不同的省份

    select distinct province as 省份

    from A_studentinfo

     

    12、查询<学生选修信息表>,查询没有填写成绩的学生的学号、课程号和成绩

    Select *

    from A_studentcourse

    where score is null

     

    13、查询<学生选修信息表>,查询全部填写了成绩的学生的选修信息,并按照“成绩”从高到低进行排序

    Select *

    from A_studentcourse

    where score is not null

    order by score desc

      

    二、聚合函数练习

    1、统计<学生信息表>,统计共有多少个学生

    Select count (*) as 学生数量

    from A_studentinfo

     

    2、统计<学生信息表>,统计年龄大于20岁的学生有多少个

    Select count(*)  as 学生数量

    from A_studentinfo

    where (2008-yearofbirth)>20

     

    3、统计<学生信息表>,统计入学时间在1980年至1982年的学生人数

    select count(*) as 学生数量

    from A_studentinfo

    where enrollment between '1998-01-01' and '2003-12-30'

     

    对比以下查询方式,看看有何不同,为什么?

    select count(*) as 学生数量

    from A_studentinfo

    where enrollment between '1998' and '2003'

     

    4、统计<学生选修信息表>,统计学号为"S001"的学生的平均成绩

    Select  avg(score)  as 平均成绩

    from A_studentcourse

    where sno='S001'

     

    5、统计<学生选修信息表>,统计学号为"S001"的学生的总成绩

    select  sum(score)  as 总成绩

    from A_studentcourse

    where sno ='S001'

     

    6、统计<学生选修信息表>,查询课程号为”C001”的课程的最高成绩

    select max(score)  as 最高成绩

    from A_studentcourse

    where cno='C001'

     

    7、统计<学生信息表>,查询所有学生中的最大年龄是多少

    select  2008-min(yearofbirth) as 最大年龄

    from  A_studentinfo

     

     

    三、分组查询练习

    1、统计<学生选修信息表>,统计每个课程的选修人数

    select cno,count(*)  as 学生数量

    from A_studentcourse

    group by cno

     

     

    2、统计<学生选修信息表>,统计每个同学的总成绩

    select sno,sum(score) as 总成绩

    from A_studentcourse

    group by sno

     

     

    3、统计<学生信息表>,统计每个班级中每种性别的学生人数,并按照班级排序

    select class as 班级,sex as 性别, count(*) as 人数

    from A_studentinfo

    group by class,sex

    order by class

     

     

    4、统计<学生选修信息表>,统计每门课程的平均成绩,并按照成绩降序排序

    Select cno,avg(score) as 平均成绩

    from A_studentcourse

    group by cno

    order by avg(score) desc

     

     

    5、统计<学生选修信息表>,显示有两门以上课程不及格的学生的学号

    Select  sno as 不及格学生学号

    from A_studentcourse

    where score<60

    group by sno

    having count(*)>1

     

     

    6、统计<学生信息表>,统计每个班级中的最大年龄是多少

    select class as 班级, 2008-min(yearofbirth) as 最大年龄

    from A_studentinfo

    group by class

      

     

    四、嵌套查询练习

    1、用子查询实现,查询选修“高等数学”课的全部学生的总成绩

    select sum(score) as 高等数学总成绩

    from A_studentcourse

    where cno =

       (

         select cno

         from A_courseinfo

         where subject='高等数学'

       )

      

      

    2、用子查询实现,统计<学生选修信息表>,显示学号为"S001"的学生在其各科成绩中,最高分成绩所对应的课程号和成绩

    select score,cno

    from A_studentcourse

    where sno='S001'

    and score =

       (

        select max(score)

        from A_studentcourse

        where sno ='S001'

       )

    思考:如果该学号学生有两个课程分数都为最高的100分,查询会有什么结果

     

     

    3、用子查询实现,查询2班选修"数据库技术"课的所有学生的成绩之和

    select  sum(score) as 数据库技术总成绩

    from A_studentcourse

    where cno =

      (

        select cno

        from A_courseinfo

        where subject='数据库技术')

    and sno in

      (

        select sno

        from A_studentinfo

        where class='2'

      )

     

    4、用子查询实现,查询3"张三"同学的"测试管理"成绩

    select score

    from A_studentcourse

    where cno=

      (

        select cno

        from A_courseinfo

        where subject='测试管理'

      )

    and sno in

      (

        select sno

        from A_studentinfo

        where class='3'

        and sname='张三'

      )

      

      

    五、联接查询练习

    1、查询"张三"的各科考试成绩,要求显示姓名、课程号和成绩

    select sname as 姓名,cno as 课程号,score as 成绩

    from A_studentinfo,A_studentcourse

    where A_studentinfo.sno=A_studentcourse.sno

    and sname='张三'

     

     

    2、查询"张三"的各科考试成绩中,哪科没有记录考试成绩,要求显示姓名、课程号和成绩

    select sname as 姓名,cno as 课程号,score as 成绩

    from A_studentinfo,A_studentcourse

    where A_studentinfo.sno=A_studentcourse.sno

    and sname='张三'

    and score is null

     

     

    3、查询"张三"的各门课程成绩,要求显示姓名、课程名称和成绩

    select sname as 姓名,subject as 课程名称,score as 成绩

    from  A_studentinfo,A_courseinfo,A_studentcourse

    where A_studentcourse.sno=A_studentinfo.sno

    and   A_studentcourse.cno=A_courseinfo.cno

    and   A_studentinfo.sname='张三'

     

     

    4、查询3"张三""测试管理"成绩,要求显示姓名、成绩

    select sname as 姓名,score as 成绩

    from  A_studentcourse,A_courseinfo,A_studentinfo

    where A_studentcourse.cno=A_courseinfo.cno

    and   A_studentcourse.sno=A_studentinfo.sno

    and subject='测试管理'

    and class='3'

    and sname='张三'

     

     

    5、查询所有2000年以前入学的,各班男生的各科考试平均成绩

    select class as 班级,avg(score) as 男生平均成绩

    from  A_studentcourse,A_courseinfo,A_studentinfo

    where A_studentcourse.cno=A_courseinfo.cno

    and  

  • 测试思路

    2010-03-09 10:04:23

    整理下目前测试中的一些思路:

    1.项目组开会,了解项目大体情况,索要项目需求或者开发文档,抽时间熟悉需求,相关数据库表、字段

    2.依据需求文档(概要设计文档、详细开发文档等)制定测试计划(提交项目、技术经理审批)

    3.依据定下来的测试计划、需求文档、概要详细文档、数据库表结构等开始前期测试用例设计(测试组、项目经理、技术经理审批)

    4.接到开发单元测试后项目(或者模块)开始正式进入前期测试环节

    5.1依据项目大小可分为3到5轮测试,所有缺陷均走BUG流程库

    5.2版本更新可分一天1次到后期一天2次,更新时间定在下午或者中午,接到更新完毕消息后开始回归测试

    5.3回归测试完毕后开始新一轮测试,3轮测试完毕,依据缺陷出现多少,严重程度、缺陷类型、优先级情况可测试组内各模块负责人进行交叉测试

    6.交叉测试提交新缺陷,开发人员修改BUG,测试人员回归测试完毕,更新版本

    7.依据BUG库缺陷分析出测试报告(提交技术、项目经理、测试经理)

    8.项目组成员开会,依据测试报告,缺陷库现有BUG讨论上线情况

    9.更新到BETA版本,开始内测

    10.内测通过发布版本供真实用户使用

  • TD搭建成功

    2009-06-03 16:37:24

    TD终于搭建成功了,现在已经开始应用到工作中,安装的时候有几个问题,一是安装时提示提示用户名,密码错误,解决方法,删除本机或者服务器一切TD安装文件重装,还无法解决的话就是给系统重新建立个管理员账户安装;

    问题二安装成功后IE7浏览器用户访问无法使用服务器TD,解决方法是为客户端用户提供IE7安装插件,或者客户端使用专门在IE7下使用的浏览器窗口就可以;

    问题三是客户端访问TD遇到字体小如何解决,为服务器安装汉化插件

  • bugfree接收邮件通知

    2008-09-02 17:29:55

    Bugfree邮件接收解决方案:

    1.在安装bugfree2.0.1目录 D:\xampp\htdocs\bugfree\Include\ 中,找到Config.inc.php文件打开

    2.Config.inc.php文件中找到如下代码行

    /* 9. SMTP param setting. */

    $_CFG['Mail']['SendParam']['Host']     = 'localhost';       // The server to connect. Default is localhost

    $_CFG['Mail']['SendParam']['SMTPAuth'] = true;    // Whether or not to use SMTP authentication. Default is FALSE

    $_CFG['Mail']['SendParam']['Username'] = 'bugfree';       // The username to use for SMTP authentication.

    $_CFG['Mail']['SendParam']['Password'] = 'bugfreemail';       // The password to use for SMTP authentication.

    修改黄色标注的内容为下方:

    /* 9. SMTP param setting. */

    $_CFG['Mail']['SendParam']['Host']     = 'mail.qq.com';

    $_CFG['Mail']['SendParam']['SMTPAuth'] = true; 

    $_CFG['Mail']['SendParam']['Username'] = 'yangcy@qq.com';   

    $_CFG['Mail']['SendParam']['Password'] = 'ycy';

    注释:如果选择的是smtp方式,需要设置smtp服务器的地址,如果smtp服务器发信需要验证,则需将SMTPAuth设成true,并设定用户名和密码。

    其中['Host']处配置为公司邮件服务器SMTP即可, ['Username']处配置为服务器POP3邮箱帐户即可

  • Windows下安装bugfree2.0.1

    2008-09-02 17:07:18

    Windows下安装bugfree

    1.     Windows服务器上安装ApachePHPMysql 软件包,例如XAMPP(我安装的是xampp1.6.7)

    安装过程:

    1)欢迎页点击next按钮

    2)选择安装目录:(注释:安装目录为中文,不可包含空格)D:\XAMPP\

    3)选择服务类型:(注释:默认即可)

    5)安装成功页点击Finish即可

    2.     启动XAMPPControlPanel,检查ApahceMySQL处于 “Running”的状态,访问 http://localhost 可以看到 XAMPP 的欢迎页面

    3.     下载bugfree2.0后解压缩包, BugFree 2.0 解压缩到 d:/xampp/htdocs

    4.     d:/xampp/htdocs/bugfree2/Include目录中,将Config.Default.php拷贝一份为 Config.inc.php。此时访问 http://localhost/bugfree2 可以看到BugFree 2.0的登录页面

    注释:在Include目录中,如有Config.inc.php文件就不需要另行拷贝了

    5.     在浏览器运行http://servername/bugfree/install.php,选择安装语言,选择全新安装,下一步

    注释:如果在此步骤中在浏览器输入URL:http://servername/bugfree/install.php 页面提示:无法访问该页面,请把该访问域名换为服务器IP地址,如:http://192.168.1.88/bugfree/install.php 即可访问到bugfree的登陆页面

    6.     点击[Install]按钮安装BugFree。安装完毕后,删除install.php文件

    7.     浏览http://servername/bugfree,使用步骤5 指定的管理员用户名和密码登陆BugFree


Open Toolbar