楼主: dliu37
1875 1

[有偿编程] 请教几道经典SQL问题!谢谢! [推广有奖]

  • 0关注
  • 0粉丝

已卖:316份资源

高中生

40%

还不是VIP/贵宾

-

威望
0
论坛币
289 个
通用积分
0
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
126 点
帖子
11
精华
0
在线时间
23 小时
注册时间
2012-9-11
最后登录
2017-4-13

楼主
dliu37 发表于 2015-6-20 04:51:10 |AI写论文
5论坛币

1) Why would you want to sometimes de-normalize data?


A. Prevent data from becoming inconsistent

B. Improve query response

C. Eliminate redundant data

D. All of the above


2) Given two tables, each with one column X of type number which is the primary key. Table A has 100 rows, Table B has 50 rows. When doing an Inner Join between A and B on X, which option would be correct?

  • The maximum possible number of rows is 100, the minimum possible number of rows 50

  • The maximum possible number of rows is 5000, the minimum possible number of rows 0

  • The maximum possible number of rows is 50, the minimum possible number of rows 0

  • The maximum possible number of rows is 100, the minimum possible number of rows 100

  • It is not possible to estimate a maximum and minimum. More information is needed.


3) Given two tables, each with one column X of type number which is the primary key. Table A has 100 rows, Table B has 50 rows. When doing a Left Outer join from A to B on X, which option would be correct?

  • The maximum possible number of rows is 100, the minimum possible number of rows 50

  • The maximum possible number of rows is 5000, the minimum possible number of rows 0

  • The maximum possible number of rows is 50, the minimum possible number of rows 0

  • The maximum possible number of rows is 100, the minimum possible number of rows 100

  • It is not possible to estimate a maximum and minimum. More information is needed.


4)Two tables A and B are given:

A          B

X Y        Y Z

1 1        2 1

2 2        2 2  

3 1        3 3  

4 2        4 5

How many rows will be in the result set of the following query?

SELECT B.Z

FROM A LEFT OUTER JOIN B

ON A.X = B.Y

  • 6 Rows

  • 5 Rows

  • 4 Rows

  • 2 Rows

  • 1 Row


5)Two tables A and B are given:

A         B

X         Y

1         1

2         2

3         5  

          7

How many rows will be in the result set of the following query?

SELECT A.X, B.Y

FROM A, B

WHERE A.X < 3 AND B.Y > = 2

  • 5 Rows

  • 6 Rows

  • 7 Rows

  • 10 Rows

  • 12 Rows


6) The following EMPLOYEE table is given:


ID   NAME        DEPT    SALARY        

1    JOHN        HR      100

2    SAM         IT      200

3    TOM         QA      150

4    NICOLE

关键词:sql information Informatio consistent inner join sometimes becoming possible primary between

沙发
jerker 发表于 2015-6-20 06:55:10
这种题目,建议楼主安装SQL环境实验,方知表之间集合关系。祝楼主学习SQL愉快。我来回答第4题,环境为SQL SERVER。

DECLARE @A TABLE(X INT,Y INT);
DECLARE @B TABLE(        Y INT ,Z INT);
INSERT INTO @A(X,Y) VALUES(1,1),(2,2),(3,1),(4,2);
INSERT INTO @B(Y,Z) VALUES(2,1),(2,2),(3,3),(4,5);
SELECT A.*,B.* FROM @A A LEFT OUTER JOIN @B B ON A.X = B.Y;
SELECT B.Z FROM @A A LEFT OUTER JOIN @B B ON A.X = B.Y;

QQ截图20150620065406.png

QQ截图20150620065406.png (28.99 KB)

QQ截图20150620065406.png

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2025-12-29 16:50