s********a 发帖数: 1447 | 1 我对这题的理解是 如果emp1 级别低于emp2 级别低于emp3 那结果就是
打印emp1收到的info
然后打印emp2都到的info
然后打印emp3收到的info
这个可不可以用类似于topological sort
parse string的时候 如果是emp1 report to emp2 of info1
那么就用emp1 -> emp2 代表
info 1就存到emp2里面
这样级别就都出来了
然后用bfs打印就好了 |
|
z*u 发帖数: 329 | 2 Try this
SELECT DISTINCT(Emp1.Salary) FROM Employee Emp1 WHERE (N-1) = (SELECT COUNT(
DISTINCT(Emp2.Salary))
FROM Employee Emp2 WHERE Emp2.Salary > Emp1.Salary) |
|
y*****e 发帖数: 712 | 3 在别的网站看到的,问了也没人理我,还请原作者见谅。
一个List,String的内容是emp向上级汇报,类似emp1 report to emp2 of
info1,也会有大boss report to himself, emp1 report to emp1 of info 2.然后需
要按每个emp收到的信息格式分级parse出来输出。请问大概的思路是怎样的?感觉像是
graph遍历。。 |
|
F*******2 发帖数: 371 | 4 谢谢楼主,并bless!
初学SQL,用的是SAS的proc SQL写的。贴出来求教有没有更简洁的code。
1.
create table sumbydept AS
select department from department AS L join employee AS R
on L.name=R.name
group by department
having sum(salary)>1000000
;
2.
create table secondhigh AS
select name From employee
where salary IN (select max(salary) as salary from employee where salary
NOT IN (select Max(salary) from employee))
Or:
SELECT *
FROM Employee Emp1
WHERE (1) =
(
SELECT COUNT(DISTINCT(Emp2.Salary))
FROM Employee Emp2
WHERE Emp2.Sala... 阅读全帖 |
|