由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - 再请教SQL问题
相关主题
sql questionTwo Intern Positions - 请帮转发
请帮忙作个SQL的题目一道小题
请帮忙做一个SQL问题[电话面试] 非死不可 2
SQL语句的两个问题SQL query 求解!
请教个SQL的问题面试SQL query 求解!
SQL find distinct values in large table (转载)SQL 面试题 - 请高手指点
SQL run a stored procedure by fetching from a cursor row by (转载)问一个数据库的题 (转载)
发个面试题这个SQL面试题怎么做
相关话题的讨论汇总
话题: grade话题: select话题: customer话题: distinct话题: orders
进入JobHunting版参与讨论
1 (共1页)
h*********n
发帖数: 915
1
table Orders:
primary key order_id, foreign key customer_id
table Customers:
primary key customer_id, name, address
find out if there's any customer not having any order.
single query, and no nested query allowed.
b******u
发帖数: 81
2
select
count*)
from
customers as c
left join orders as o on (c.customerid = o.customerid)
where
o.customerid is null
s**********e
发帖数: 326
3
select customer_id
from Customers
minus
select distinct customer_id
from Orders
order by customer_id;

【在 h*********n 的大作中提到】
: table Orders:
: primary key order_id, foreign key customer_id
: table Customers:
: primary key customer_id, name, address
: find out if there's any customer not having any order.
: single query, and no nested query allowed.

h*********n
发帖数: 915
4
您这个还是两次查询啊。

【在 s**********e 的大作中提到】
: select customer_id
: from Customers
: minus
: select distinct customer_id
: from Orders
: order by customer_id;

h*********n
发帖数: 915
5
这个可以。
再来一个:学生编号,课程,成绩。判断是否有一个学生所有成绩没有F也没有A。每个
学生选的课可能不同。
Records: Id, Course, Grade

【在 b******u 的大作中提到】
: select
: count*)
: from
: customers as c
: left join orders as o on (c.customerid = o.customerid)
: where
: o.customerid is null

z****h
发帖数: 164
6
select distinct id from records where grade <> 'f' and grade <>'a'
h*********n
发帖数: 915
7
这个是至少一门在B和D之间的所有学生。
找的是至少一个学生,所有成绩在B到D之间。

【在 z****h 的大作中提到】
: select distinct id from records where grade <> 'f' and grade <>'a'
z****h
发帖数: 164
8
select distinct id from records where grade between 'b' and 'd'
b******u
发帖数: 81
9
select
studentid
from
Grade
group by
studentid
having
(
max(case when grade = 'A' then 1 else 0 end ) = 0 and
max(case when grade = 'F' then 1 else 0 end ) = 0
)
z****h
发帖数: 164
10
select distinct id from records where id not in (select distinct id from
records where grade = 'a' or grade = 'f')
g*****e
发帖数: 282
11
分别用not exist和between。效率更高,主要是能否利用index的考虑

【在 z****h 的大作中提到】
: select distinct id from records where id not in (select distinct id from
: records where grade = 'a' or grade = 'f')

1 (共1页)
进入JobHunting版参与讨论
相关主题
这个SQL面试题怎么做请教个SQL的问题
发个FB电面SQL题目攒个人品希望H1B抽中SQL find distinct values in large table (转载)
keep group of values of SQL procedure in one table (转载)SQL run a stored procedure by fetching from a cursor row by (转载)
SQL select one value column for each distinct value another col发个面试题
sql questionTwo Intern Positions - 请帮转发
请帮忙作个SQL的题目一道小题
请帮忙做一个SQL问题[电话面试] 非死不可 2
SQL语句的两个问题SQL query 求解!
相关话题的讨论汇总
话题: grade话题: select话题: customer话题: distinct话题: orders