<pre id="bbfd9"><del id="bbfd9"><dfn id="bbfd9"></dfn></del></pre>

          <ruby id="bbfd9"></ruby><p id="bbfd9"><mark id="bbfd9"></mark></p>

          <p id="bbfd9"></p>

          <p id="bbfd9"><cite id="bbfd9"></cite></p>

            <th id="bbfd9"><form id="bbfd9"><dl id="bbfd9"></dl></form></th>

            <p id="bbfd9"><cite id="bbfd9"></cite></p><p id="bbfd9"></p>
            <p id="bbfd9"><cite id="bbfd9"><progress id="bbfd9"></progress></cite></p>

            sql語句相關測試

            時間:2024-07-09 02:04:23 SQL 我要投稿
            • 相關推薦

            sql語句相關測試

              篇一:SQL語句測試

              1、(10分)要求:

              選擇受理時間在2008-5-1 到 2008-6-1之間的所有申請人姓氏為“劉”的數據,并把“新受理編號”列表示成當前機器時間的年月和原受理編號年月后的數值組合

              格式如下:

              受理編號,新受理編號,受理時間, 申請人

              200801112 201008112 2008-01-13劉XX

              需要的表

              I_Optinst 業務實例表

              REGDATE(受理日期)

              Regnum(受理編號)

              Proposer(申請人)

              解答:select Regnum as 受理編號, as 新受理編號,REGDATE as 受理時間,Proposer as申請人 from Optinst 2、(15分)要求:

              前提:只統計業務小類“存量房買賣”

              ①按照月份分12月列出2008年每個月份的月份對應月份的交易總面積

              ②按照月份分12月列出2008年每個月份的月份對應月份的交易均價(申報價格/建筑面積)

              格式

              年度月份 交易總面積 年度月份交易均價(元/平方米)

              2008-01 23232 2008-01 2323

              2008-02 23232008-02 232

              2008-03 232323 2008-03 7656

              2008-04 232323 2008-03 565

              2008-05 232323 2008-03 5656

              2008-06 232323 2008-03 565

              2008-07 232323 2008-03 67

              2008-08 232323 2008-03 676

              2008-09 232323 2008-03 6767

              2008-10 232323 2008-03 8686

              2008-11 232323 2008-03 867

              2008-12 232323 2008-03 454

              需要的表:

              Fc_room 房間表

              BAREA(建筑面積)

              I_Optinst業務實例表

              regdate(受理時間)

              fc_owner 產權表

              COSTVAL(申報價格)

              EVLVAL(評估價格)

              fc_owoom 房間明細表

              1.select regdate as年度月份,BAREA as 交易總面積 from Fc_room,Optinst where

              3、(20分)要求:

              ①:按照時間統計收費明細 統計格式如下

              受理編號繳費人收費日期 收費名稱收費金額核費人收費人

              ②:按照時間匯總(2008年度)統計收費項目分類 統計格式如下

              收費名稱 總金額

              需要的表:

              I_OptInst(業務實例表)

              Regnum 受理編號

              Proposer 申請人

              I_Charge(收費實例表)

              HEFEIMAN 核費人

              PAYEE 收款人

              CDATE 收費日期

              I_ChrDtl(收費實例明細表

              CNAME 收費名稱

              MONEY 收費金額

              4、(15分)要求:用途是住宅并且建筑面積<=140>140 定義為 “非普通住宅”

              用途是商業并且建筑面積>140 定義為 “商業A級”

              其他情況定義為“非住宅”

              根據用途和面積列表出所有數據

              格式

              受理編號, 用途

              200406000386 普通住宅

              200406004631 非普通住宅

              200406004633 普通住宅

              200406004638 普通住宅

              200406004641 非住宅

              200501000004 普通住宅

              200406004568 非住宅

              200406005677 商業A級

              表:

              fc_room

              barea 建筑面積

              BUse 用途

              i_optinst

              regnum 受理編號

              5、(30分)工作量統計

              ① 選擇出以下格式的數據;并創建視圖名稱為view_AAAA

              業務小類業務實例 交易價格建筑面積 登記時間

              1 存量房買賣 14100 19400.0029.98 2005-11-10 11:32:50 2 新建商品房 15041 229530.00 124.07 2005-11-21 08:59:36 3 新建商品房 15043 177363.00 101.35 2005-11-21 09:15:59 4 新建商品房 13046 71130.0023.71 2005-11-02 10:15:37 5 新建商品房 11280 148563.00 87.39 2005-10-11 09:50:48 6 新建商品房 11353 267369.00 116.04 2005-10-11 15:34:53 7 房改售房 2689 35.22 2004-06-17 08:43:00 8 產權人名稱變更 11701 724.18 2005-10-17 10:05:20 9 新建商品房 7206 158257.00 88.69 2005-09-16 14:50:57 10 存量房買賣 (轉 載于:wWw.cnboThwiN.cOM 博 威范文 網:sql語句測試)10100 103.07 2005-08-31 20:27:06 11 存量房買賣 12980 51500.0046.66 2005-11-01 14:41:32 12 新建商品房 13000 136782.00 80.46 2005-11-01 15:37:05 13 新建商品房 16946 300844.00 146.33 2005-12-15 14:15:07 14 存量房買賣 10091 509.18 2005-08-31 19:19:25 ② 使用視圖 view_AAAA 當做表 選擇出如下樣式數據

              業務小類 件數合計金額 合計面積

              1 用途變更 1151.3

              2 轉移登記 184.03

              3 新建商品房 31 263243643197.34

              4 房改售房 8252.43

              5 產權人名稱變更 3 778.6

              6 單位產新建 311697.49

              7 贈與 1 28.48

              8 存量房買賣 24 4379004134.67

              9 判決仲裁 2 439.41

              10 繼承遺贈 1 49.17

              11 換證 2 228.88

              12 新建房屋 17 928.91

              ③ 用水晶報表關聯視圖 view_AAAA 設計出類似于②的數據格式 需要的表

              FC_Owner

              EvlVal交易價格

              I_OptInst,

              SOName 業務小類

              fc_owoom,

              BArea 建筑面積

              FC_Room

              regdate 受理日期

              篇二:sql查詢語句學習測試答案

              第一部分SQL查詢語句的學習

              單表查詢 1、--查詢訂購日期在1996年7月1日至1996年7月15日之間的訂單的訂購日期、訂單ID、客戶ID和雇員ID等字段的值

              use eee

              SELECT 訂購日期,訂單ID,客戶ID,

              雇員ID

              FROM 訂單

              WHERE 訂購日期BETWEEN '1996-7-1 00:00:00' AND '1996-7-15 23:59:59'

              2、--查詢“Northwind”示例數據庫中供應商的ID、公司名稱、地區、城市和電話字段的值。條件是“地區等于華北”并且“聯系人頭銜等于銷售代表”。

              use eee

              SELECT 供應商ID,公司名稱,地區,城市,電話

              FROM 供應商

              WHERE 地區='華北' AND 聯系人職務='銷售代表'

              3、--查詢“Northwind”示例數據庫中供應商的ID、公司名稱、地區、城市和電話字段的值。其中的一些供應商位于華東或華南地區,另外一些供應商所在的城市是天津 use eee

              SELECT 供應商ID,公司名稱,地區,城市,電話

              FROM 供應商

              WHERE 地區IN('華東', '華南') OR 城市='天津'

              4、--查詢“Northwind”示例數據庫中位于“華東”或“華南”地區的供應商的ID、公司名稱、地區、城市和電話字段的值

              use eee

              SELECT 供應商ID,公司名稱,地區,城市,電話

              FROM 供應商

              WHERE 地區IN('華東', '華南')

              多表查詢 5、--查詢訂購日期在1996年7月1日至1996年7月15日之間的訂單的訂購日期、訂單ID、相應訂單的客戶公司名稱、負責訂單的雇員的姓氏和名字等字段的值,并將查詢結果按雇員的“姓氏”和“名字”字段的升序排列,“姓氏”和“名字”值相同的記錄按“訂單 ID”的降序排列

              use eee

              SELECT 訂購日期,訂單ID,公司名稱,姓氏,名字

              FROM 訂單,雇員,客戶

              WHERE 訂購日期BETWEEN '1996-7-1 00:00:00' AND '1996-7-15 23:59:59'

              AND 訂單.雇員ID = 雇員.雇員ID

              AND 訂單.客戶ID = 客戶.客戶ID

              ORDER BY 姓氏,名字ASC,訂單ID DESC

              6、--查詢“10248”和“10254”號訂單的訂單ID、運貨商的公司名稱、訂單上所訂購的產品的名稱

              use eee

              SELECT 訂單.訂單ID,公司名稱,產品名稱

              FROM 訂單,運貨商,產品,訂單明細

              WHERE 訂單.訂單ID IN('10248','10254')

              AND 訂單.訂單ID = 訂單明細.訂單ID

              AND 訂單明細.產品ID = 產品.產品ID

              AND

              訂單.運貨商= 運貨商.運貨商ID

              7、--查詢“10248”和“10254”號訂單的訂單ID、訂單上所訂購的產品的名稱、數量、單價和折扣

              use eee

              SELECT 訂單.訂單ID,產品名稱,數量,訂單明細.單價,折扣

              FROM 訂單,產品,訂單明細

              WHERE 訂單.訂單ID IN('10248','10254')

              AND 訂單.訂單ID = 訂單明細.訂單ID

              AND 訂單明細.產品ID = 產品.產品ID

              篇三:sql語句練習題及答案

              一 在數據庫 school 中建立student , sc, course 表。

              學生表、課程表、選課表屬于數據庫 School ,其各自的數據結構如下:

              學生 Student (Sno,Sname,Ssex,Sage,Sdept)

              課程表 course(Cno,Cname,Cpno,Ccredit)

              學生選課 SC(Sno,Cno,Grade)

              二 設定主碼

              1 Student表的主碼:sno2 Course表的主碼:cno 3 Sc表的主碼:sno,cno

              1寫出使用 Create Table 語句創建表 student , sc, course 的SQL語句

              2

              3 刪除student表中的元組

              4在數據庫school中刪除關系student

              5在student表添加屬性sbirthdate 類型 datetime

              Delete

              1 刪除所有 JSJ 系的男生 from Student where Sdept=’JSJ’ and Ssex=’男’; 2 刪除“數據庫原理”的課的選課紀錄

               from SC where Cno in (select Cno fromCourse where Cname=’數據庫原理’);

              Update

              1 修改 0001 學生的系科為: JSJ

              2 把陳小明的年齡加1歲,性別改為女。 2 修改李文慶的1001課程的成績為 93 分 3 把“數據庫原理”課的成績減去1分

              Select 查詢語句

              一 單表

              1查詢年齡在19至21歲之間的女生的學號,姓名,年齡,按年齡從大到小排列。 2查詢姓名中第2個字為“明”字的學生學號、性別。 3查詢 1001課程沒有成績的學生學號、課程號

              4查詢JSJ 、SX、WL 系的年齡大于25歲的學生學號,姓名,結果按系排列 5按10分制查詢學生的sno,cno,10分制成績

              (1-10分 為1 ,11-20分為2 ,30-39分為3,。。。90-100為10) 6查詢 student 表中的學生共分布在那幾個系中。(distinct) 7查詢0001號學生1001,1002課程的成績。

              二 統計

              1查詢姓名中有“明”字的學生人數。 2計算‘JSJ’系的平均年齡及最大年齡。 3查詢學生中姓名為張明、趙英的人數

              4計算每一門課的總分、平均分,最高分、最低分,按平均分由高到低排列 5 計算 1001,1002 課程的平均分。

              6 查詢平均分大于80分的學生學號及平均分 7 統計選修課程超過 2 門的學生學號

              8 統計有10位成績大于85分以上的課程號。 9 統計平均分不及格的學生學號

              10 統計有大于兩門課不及格的學生學號

              三 連接

              1查詢 JSJ 系的學生選修的課程號

              2查詢選修1002 課程的學生的學生姓名 (不用嵌套及嵌套2種方法) 3查詢數據庫原理不及格的學生學號及成績

              4查詢選修“數據庫原理”課且成績 80 以上的學生姓名(不用嵌套及嵌套2種方法) 5查詢平均分不及格的學生的學號,姓名,平均分。 6查詢女學生平均分高于75分的學生姓名。

              7查詢男學生學號、姓名、課程號、成績。(一門課程也沒有選修的男學生也要列出,不能

              四 嵌套、相關及其他

              1 查詢平均分不及格的學生人數

              2 查詢沒有選修1002 課程的學生的學生姓名

              3 查詢平均分最高的學生學號及平均分 (2種方法 TOP , any , all) *4 查詢沒有選修1001,1002課程的學生姓名。

              5 查詢1002課程第一名的學生學號(2種方法) 6 查詢平均分前三名的學生學號

              7 查詢 JSJ 系的學生與年齡不大于19歲的學生的差集

              8 查詢1001號課程大于90分的學生學號、姓名及平均分大于85分的學生學號、姓名 9 查詢每門課程成績都高于該門課程平均分的學生學號 10 查詢大于本系科平均年齡的學生姓名

              答案

              參考答案

              1 create table student (sno6), sname var8), ssex2), sagesmallint, sdept var15), primary key(sno));

              create table sc

              (sno6), cno 4),

              grade decimal(12,2), primary key(sno,cno));

               into student

              values( ’4001’,’趙茵’,’男’,20,’SX’)

               from student

               student

              alter table student add sbirthdate datetime

              1 select sno, sname, sage from student

              where ssex=’女’ and sage between 19 and 21order by sage desc; 2 select sno, ssexfrom student

              where sname like ’_明% ’ ; 3 select sno, cnofrom sc

              where grade is null and cno=’1001’ ; 4 select sno, sname from student

              where sdept in (’JSJ’,’SX’,’WL’) and sage>25 group by sdept;

              select sno, cno, grade/10.0+1 as levelfrom sc ;

              select distinct sdept from student ; select grade from sc

              where sno=’0001’ and (cno=’1001’ or cno=’1002’) ;

              select count(*) from student where sname like ’%明% ’ ; select avg(sage),max(sage) from student where sdept=’JSJ’ ; select cno,sum(grade),avg(grade),max(grade),min(grade) from sc group by cno

              order by avg(grade) desc ;

              select cno, avg(grade) from sc where cno in(‘1001’,’1002’) group by cno ;

              select sc.sno ,avg(grade) from scgroup by sc.sno

              having avg(grade)>80 ;

              select sno from sc group by sno having count(*)>2 ;

              select cno from sc where grade>85 group by cno having count(*)=10 ; select sno from sc group by sno having avg(grade)<60 ;

              select sno from sc where grade<60 group="" by="" sno="" having="">2 ;

              select cno from student,sc where student.sno=sc.sno and sdept=’JSJ’ ; a:select sname from student,sc where student.sno=sc.sno and cno=’1002’

              b:select sname from student where sno in (select sno from sc where cno=’1002’)

              select sno,grade from sc,course

              where sc.cno=course.cno and cname=’數據庫原理’ and grade<60 a:select sname from student ,sc,course

              where student.sno=sc.sno and sc.cno=course.cno and grade>80 and cname=’ 數據庫原理’ b:select sname from student where sno in (select sno from sc where grade>80 and cno in (select cno from course where cname=’ 數據庫原理’)) select sno,sname,avg(grade) from sc,studentwhere student.sno=sc.snogroup by student.sno having avg(grade)<60

              a:select sname from student where ssex=’女’ and sno in(select sno from sc group by sno having avg(grade)>75)

              b:select sname from sc,student where student.sno=sc.sno and ssex=’女’group by student.sno having avg(grade)>75

              select student.sno,sname,cno,grade from student left join sc on student.sno=sc.sno and ssex=’男’

              select count(*) from student where sno in( select sno from sc group by sno havingavg(grade)<60)

              select sname from student where sno not in(select sno from sc where cno=’1002’)

              student

              0001 aaX 0002 bb

              0003 ccX Sc

              0001 1001 0001 1002 0002 1001 0003 1002

              Select sname from student where not exists(select* from sc where cno=’1002’ and sc.sno=student.sno)

              a:select top 1 sno,avg(grade) from sc group by sno order by avg(grade) desc b:select sno, avg(grade) from sc group by sno

              having avg(grade)=(select top 1 avg(grade) from scgroup by sno order by avg(grade) desc) c:select sno, avg(grade) from sc group by sno

              having avg(grade)>=all ( select avg(grade) from sc group by sno)

              select sname from student where not exists(

              select * from course where cno in(‘1001’,’1002’) and

              not exists(select * from sc where sno =student.sno and cno=course.cno) ) a:select top 1 sno from sc cno=’1002’ order by grade desc b:select sno from sc where cno=’1002’ and grade >=all (

            【sql語句相關測試】相關文章:

            oracle的sql語句01-21

            SQL查詢語句大全10-24

            SQL語句的理解原則10-05

            mysql SQL語句積累參考10-02

            sql語句的各種模糊查詢08-25

            Oracle的sql語句模擬試題及答案10-12

            SQL語句中的正則表達示07-28

            SQL優化大全09-09

            2016最新J2EE中SQL語句自動構造方法08-02

            PHP防止SQL注入的例子09-25

                    <pre id="bbfd9"><del id="bbfd9"><dfn id="bbfd9"></dfn></del></pre>

                    <ruby id="bbfd9"></ruby><p id="bbfd9"><mark id="bbfd9"></mark></p>

                    <p id="bbfd9"></p>

                    <p id="bbfd9"><cite id="bbfd9"></cite></p>

                      <th id="bbfd9"><form id="bbfd9"><dl id="bbfd9"></dl></form></th>

                      <p id="bbfd9"><cite id="bbfd9"></cite></p><p id="bbfd9"></p>
                      <p id="bbfd9"><cite id="bbfd9"><progress id="bbfd9"></progress></cite></p>
                      飘沙影院