zoukankan      html  css  js  c++  java
  • 6.08练习

    create database gongsi
    use gongsi
    go
    
    create table bumen
    (
        bcode int primary key not null,
        bname varchar(20),
        bceo varchar(20),
        btel varchar(20),
    )
    go
    create table renyuan
    (
        code int primary key identity(10001,1) not null,
        name varchar(20),
        sex char(10),
        age int,
        cid varchar(20),
        tel varchar(20),
        bumen int 
    )
    go
    
    insert into bumen values(1001,'财务部','张三','1234567')
    insert into bumen values(1002,'企划部','李四','2345678')
    insert into bumen values(1003,'市场部','王五','3456789')
    insert into bumen values(1004,'客服部','赵六','4567890')
    go
    
    insert into renyuan values('张三','',33,'123456789012345678','1234567',1001)
    insert into renyuan values('张全蛋','',29,'234567890123456789','7654321',1001)
    insert into renyuan values('','',33,'3456789012345677777','8765432',1001)
    
    insert into renyuan values('李四','',45,'789012345678903456','2345678',1002)
    insert into renyuan values('李莲英','',55,'890789078907895622','6789056',1002)
    insert into renyuan values('李虎','',45,'456789076543265443','8765434',1002)---------
    
    insert into renyuan values('王五','',37,'876542345798765434','6543234',1003)
    insert into renyuan values('王二麻','',32,'23456876542345873','2376532',1003)
    insert into renyuan values('王二丫','',23,'12345654322345654','6542346',1003)
    insert into renyuan values('王查查','',23,'12345654322345654','6542346',1003)
    insert into renyuan values('王甜','',23,'12345654322345654','6542346',1003)
    
    
    insert into renyuan values('赵六','',26,'234765423456222','9874533',1004)
    insert into renyuan values('赵敏','',25,'5434567765433456','7623456',1004)
    insert into renyuan values('赵英俊','',32,'125432886543225','8565424',1004)
    go
    
    
    
    --查找--查找所有男同志里面年龄最大的人的信息
    select * from renyuan  where code=
    (select top 1 code from renyuan where age=
    (select  MAX(age) from renyuan where sex=''))
    
    select * from bumen 
    select * from renyuan
    
    
    ---查询人数最多的部门里年龄最大的人的信息
    select bumen from renyuan group by bumen having COUNT(*)>4
    select MAX(age) from renyuan where bumen=1003
    select code from renyuan where bumen=1003 and age =37
    select * from renyuan where code=1007
    
    
    select * from renyuan where code=
    (select code from renyuan where bumen=1003 and age =37)
    
    go
    --按照年龄从小到大排序,取789号人员的所有信息
    select top 3 * from renyuan where code not in
    (select top 6 code from renyuan order by age) order by age
    
    
    --将人员表显示出来   并且将部门编号变为部门名称显示
    select name , sex ,(select bname from bumen where bumen.bcode = renyuan.bumen) from renyuan
    
    
    --分页查询
    select top 5 * from renyuan
    --6~10
    select top 5 * from renyuan where code not in
    (select top 5 code from renyuan)
  • 相关阅读:
    cf 786B. Legacy(线段树区间建图)
    cf 1416D. Graph and Queries (生成树重构+线段树维护dfs序)
    cf 1437E. Make It Increasing
    cf 1434D. Roads and Ramen (树上最长偶权链)
    cf 1413C (贪心排序+双指针)
    cf 1421E. Swedish Heroes (dp)
    CF1428 F.Fruit Sequences
    11.Redis详解(十一)------ 过期删除策略和内存淘汰策略
    10.Redis详解(十)------ 集群模式详解
    9.Redis详解(九)------ 哨兵(Sentinel)模式详解
  • 原文地址:https://www.cnblogs.com/a454966933/p/5570558.html
Copyright © 2011-2022 走看看