求一sql语句 - Oracle / 开发
两个表
请看 "Persons" 表:
name banji shunxu
yiyang 01 1
yiyang 02 1
lili 01 2
接下来请看 "xueke" 表:
name kemu shunxu
yiyang 01-yingyu 1
yiyang 01-shuxue 1
yiyang 02-yingyu 1
lili 01-yuwen 2
第一个表每个学生有两条记录,也可能一条,第二个表就有多个记录与之对应
我现在想取出第一个表中的姓名,第二个表中所有的记录,如果用join就double记录了。
select a.name,b.kemu from persons a,xueke b where a.name = b.name order by shunxu
这样记录就双倍。用union的话不能和order by同时使用,请大家帮忙
order by可以放到最后或者加一个子查询啊..
select a.name,b.kemu,B.SHUNXU
from (SELECT DISTINCT NAME from persons ) a,
xueke b
where a.name = b.name
order by B.shunxu
xueke表里本身就有name了,应该只是对照看表persons里是否有记录吧..
SQL code:
SELECT NAME, kemu, shunxu
from xueke a
WHERE EXISTS (SELECT '*'
from persons b
WHERE b.NAME = a.NAME)
select * from (select a.name,b.kemu from persons a,xueke b where a.banji='01' and a.name =b.name order by a.shenxu) from a
union
select * from (select a.name,b.kemu from persons a,xueke b where a.ba
相关问答:
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jas ......
假设table01 中有 以下资料
emp_no emp_name
------- ------------
0001 TOM
0002 JOHN
0003 MARY
常用电话
而我们要得到以下的OUTPUT (或是各种其他的output)
0001,TOM
0002,JOHN
......
oracle 11g 安装 01092 错误,
日志信息:
[oracle@linux trace]$ vi alert_orcl.log
MMON started with pid=14, OS id=9089
RESETLOGS after incomplete recovery UNTIL CHANGE 522752
Errors in file / ......
sql的软件在哪里可以下啊!在网上找了蛮多都用不了啊
随便搞一D版吧,
迅雷第一个就可以用
2000,2005都这样
http://119.147.41.16/down?cid=0698C2D64D7D637D90A6D2482298E6717D4F15CD&t=2&fmt=-1 ......
字段1,字段2.....字段N,Status,ParentID
1,Name1....test1,1,99
1,Name1....test1,3,99
1,Name2....test2,1,101
1,Name2....test2,3,101
1,Name3....test3,2,101
1,Name1....test1,4,101
想要的结果是:
1,Na ......