zoukankan      html  css  js  c++  java
  • 数据库常用面试题

    解答: 

    --1
    select * from students where sid in
    (select r_sid from sresult where r_cid=(select cid from Course where cname='税收基础'))
    --2
    select * from students where sid in
    (select r_sid from SResult where r_cid =2)
    --3
    select * from students where sid not in
    (select r_sid from SResult where r_cid =5)
    --4
    select * from dbo.Students where sid in
    (
    select r_sid from  SResult group by r_sid having count(*) =
    (select count(*) from Course)
    )
    --5
    select count(distinct r_sid) from sresult
    --select count(*) from
    --(select r_sid from sresult
    --group by r_sid) a
    --6

    select * from dbo.Students where sid in
    (
    select r_sid from  SResult group by r_sid having count(*) >5
    )

    解答:

    --1
    select * from students where st_id in
    (select r_stid from Results where r_tid not in
    (select t_id from dbo.Teachers where t_name='李明'))
    --2
    select a.st_name,b.fenshu from Students a,
    (select r_stid,avg(r_fenshi) as fenshu from Results where r_fenshi <60 group by r_stid having count(*) >=2) b
    where a.st_id = b.r_stid
    --3

    select * from Students where st_id in
    (
    select r_stid from Results where r_tid in
    (select t_id from Teachers where t_lesson='数学' or t_lesson='英语')
    group by r_stid having count(*) =2
    )
    --4
    select r_stid from Results
    where r_fenshi >
    (select r_fenshi from dbo.Results where r_tid='t001' and r_stid='st002')
    and r_tid ='t001'

    --5
    --select * from dbo.Students
    --select * from dbo.Teachers
    select * from (select * from Results where r_tid ='t001') a,(select * from Results where r_tid ='t002') b
    where
     a.r_stid =b.r_stid
    and a.r_fenshi >b.r_fenshi

    --select * from Results where (r_tid ='t001' or r_tid ='t002') and  r_stid in ('st001','st002','st003') order by r_stid
    --select * from Results where r_tid ='t002' order by r_stid

  • 相关阅读:
    NLPIR大数据语义系统文本数据分析挖掘平台
    NLPIR:中文语义挖掘是自然语言处理的关键
    NLPIR-JZSearch智能搜索深层挖掘大数据资源
    NLPIR智能Protege知识图谱实现多场景应用
    DotNet加密方式解析--散列加密
    SSO单点登录PHP简单版
    xss框架基础框架实现
    Kafka Offset Storage
    C#如何使用ES
    模拟Vue之数据驱动
  • 原文地址:https://www.cnblogs.com/jasonjiang/p/1763779.html
Copyright © 2011-2022 走看看