这句话怎么理解:求表d中num1和num2分别符合一个条件的个数
解决方案 »
- 关于ORACLE 10G 数据库当前已关闭
- 数据结构难题请教: 经营模式共有四类, 要求可以复选, 但查询时只许选择一种进行搜索?
- 反向like型的条件怎么弄?
- 关于Top sql的问题
- 一个update语句的速度问题!各位高人来帮忙看看
- 初级问题¥¥高手请告诉我如何才能显示时分秒呢?以及to_date的两个问题。谢谢!
- SQLPlus的中文问题
- 由于当前驱动器的空间不够用了,能不能把表空间建在另外的驱动器上?
- 关于数据库访问的问题(表或视图不存在)
- 将一个含有子分区的数据imp到另一个数据库中,该如何操作?
- orcale 11G创建数据出错
- oracle 数据库查询问题~求各位oracle指点迷津~最好告诉答案~
这句话怎么理解:求表d中num1和num2分别符合一个条件的个数
把a_id 传入
并且num1和num2还要分别同时符合两个不同的条件例如
num1 = 1并且 num2 = 2.
这句话怎么理解:求表d中num1和num2分别符合一个条件的个数
把a_id 传入
并且num1和num2还要分别同时符合两个不同的条件例如
num1 = 1并且 num2 = 2.
意思是num1和num2不能相等,是吗?
这句话怎么理解:求表d中num1和num2分别符合一个条件的个数
把a_id 传入
并且num1和num2还要分别同时符合两个不同的条件例如
num1 = 1并且 num2 = 2.
意思是num1和num2不能相等,是吗?
这两列没有关系!只是他们有自己独立成立的条件。他们可以相等,也可以不相等。
这句话怎么理解:求表d中num1和num2分别符合一个条件的个数
把a_id 传入
并且num1和num2还要分别同时符合两个不同的条件例如
num1 = 1并且 num2 = 2.
意思是num1和num2不能相等,是吗?
这两列没有关系!只是他们有自己独立成立的条件。他们可以相等,也可以不相等。
select t1.id, t1.name, t1.c_count
from (select a.id, a.name, count(c.b_id) c_count
from a, c
where a.id = c.a_id
and a.name = p_name) t1,
(select a.id, a.name, count(d.a_id) d_count
from a, d
where a.id = d.a_id
and d.num1 = 'tiaojian1'
and d.num2 = 'tiaojian2'
and a.name = p_name) t2
where t1.id = t2.id
and t1.c_count = t2.d_count
这句话怎么理解:求表d中num1和num2分别符合一个条件的个数
把a_id 传入
并且num1和num2还要分别同时符合两个不同的条件例如
num1 = 1并且 num2 = 2.
意思是num1和num2不能相等,是吗?
这两列没有关系!只是他们有自己独立成立的条件。他们可以相等,也可以不相等。
select t1.id, t1.name, t1.c_count
from (select a.id, a.name, count(c.b_id) c_count
from a, c
where a.id = c.a_id
and a.name = p_name) t1,
(select a.id, a.name, count(d.a_id) d_count
from a, d
where a.id = d.a_id
and d.num1 = 'tiaojian1'
and d.num2 = 'tiaojian2'
and a.name = p_name) t2
where t1.id = t2.id
and t1.c_count = t2.d_count
如果p_name来源于表a,但是表a中p_name会有重复的
这句话怎么理解:求表d中num1和num2分别符合一个条件的个数
把a_id 传入
并且num1和num2还要分别同时符合两个不同的条件例如
num1 = 1并且 num2 = 2.
意思是num1和num2不能相等,是吗?
这两列没有关系!只是他们有自己独立成立的条件。他们可以相等,也可以不相等。
select t1.id, t1.name, t1.c_count
from (select a.id, a.name, count(c.b_id) c_count
from a, c
where a.id = c.a_id
and a.name = p_name) t1,
(select a.id, a.name, count(d.a_id) d_count
from a, d
where a.id = d.a_id
and d.num1 = 'tiaojian1'
and d.num2 = 'tiaojian2'
and a.name = p_name) t2
where t1.id = t2.id
and t1.c_count = t2.d_count
如果p_name来源于表a,但是表a中p_name会有重复的
p_name是你传给a表作为条件的name
这句话怎么理解:求表d中num1和num2分别符合一个条件的个数
把a_id 传入
并且num1和num2还要分别同时符合两个不同的条件例如
num1 = 1并且 num2 = 2.
意思是num1和num2不能相等,是吗?
这两列没有关系!只是他们有自己独立成立的条件。他们可以相等,也可以不相等。
select t1.id, t1.name, t1.c_count
from (select a.id, a.name, count(c.b_id) c_count
from a, c
where a.id = c.a_id
and a.name = p_name) t1,
(select a.id, a.name, count(d.a_id) d_count
from a, d
where a.id = d.a_id
and d.num1 = 'tiaojian1'
and d.num2 = 'tiaojian2'
and a.name = p_name) t2
where t1.id = t2.id
and t1.c_count = t2.d_count
如果p_name来源于表a,但是表a中p_name会有重复的
p_name是你传给a表作为条件的name如果p_name来源于表a 再作为name条件
这句话怎么理解:求表d中num1和num2分别符合一个条件的个数
把a_id 传入
并且num1和num2还要分别同时符合两个不同的条件例如
num1 = 1并且 num2 = 2.
意思是num1和num2不能相等,是吗?
这两列没有关系!只是他们有自己独立成立的条件。他们可以相等,也可以不相等。
select t1.id, t1.name, t1.c_count
from (select a.id, a.name, count(c.b_id) c_count
from a, c
where a.id = c.a_id
and a.name = p_name) t1,
(select a.id, a.name, count(d.a_id) d_count
from a, d
where a.id = d.a_id
and d.num1 = 'tiaojian1'
and d.num2 = 'tiaojian2'
and a.name = p_name) t2
where t1.id = t2.id
and t1.c_count = t2.d_count
如果p_name来源于表a,但是表a中p_name会有重复的
p_name是你传给a表作为条件的name如果p_name来源于表a 再作为name条件
现在业务是这样的,查询每个name符合之前条件的那个表a 数据
这句话怎么理解:求表d中num1和num2分别符合一个条件的个数
把a_id 传入
并且num1和num2还要分别同时符合两个不同的条件例如
num1 = 1并且 num2 = 2.
意思是num1和num2不能相等,是吗?
这两列没有关系!只是他们有自己独立成立的条件。他们可以相等,也可以不相等。
select t1.id, t1.name, t1.c_count
from (select a.id, a.name, count(c.b_id) c_count
from a, c
where a.id = c.a_id
and a.name = p_name) t1,
(select a.id, a.name, count(d.a_id) d_count
from a, d
where a.id = d.a_id
and d.num1 = 'tiaojian1'
and d.num2 = 'tiaojian2'
and a.name = p_name) t2
where t1.id = t2.id
and t1.c_count = t2.d_count
如果p_name来源于表a,但是表a中p_name会有重复的
p_name是你传给a表作为条件的name如果p_name来源于表a 再作为name条件
关键是你通过什么条件取出p_name
这句话怎么理解:求表d中num1和num2分别符合一个条件的个数
把a_id 传入
并且num1和num2还要分别同时符合两个不同的条件例如
num1 = 1并且 num2 = 2.
意思是num1和num2不能相等,是吗?
这两列没有关系!只是他们有自己独立成立的条件。他们可以相等,也可以不相等。
select t1.id, t1.name, t1.c_count
from (select a.id, a.name, count(c.b_id) c_count
from a, c
where a.id = c.a_id
and a.name = p_name) t1,
(select a.id, a.name, count(d.a_id) d_count
from a, d
where a.id = d.a_id
and d.num1 = 'tiaojian1'
and d.num2 = 'tiaojian2'
and a.name = p_name) t2
where t1.id = t2.id
and t1.c_count = t2.d_count
如果p_name来源于表a,但是表a中p_name会有重复的
p_name是你传给a表作为条件的name如果p_name来源于表a 再作为name条件
关键是你通过什么条件取出p_name这个p_name是表中的每个name都要传入去看是否符合条件
这句话怎么理解:求表d中num1和num2分别符合一个条件的个数是不是把(select distinct p_name from a)来替换p_name?
这句话怎么理解:求表d中num1和num2分别符合一个条件的个数是不是把(select distinct p_name from a)来替换p_name?select distinct t3.id, t3.name
from a t3,
(select t1.id
from (select a.id, count(c.b_id) c_count
from a, c
where a.id = c.a_id
group by a.id) t1,
(select a.id, count(d.a_id) d_count
from a, d
where a.id = d.a_id
and d.num1 = 'tiaojian1'
and d.num2 = 'tiaojian2'
group by a.id) t2
where t1.id = t2.id
and t1.c_count = t2.d_count) t4
where t3.id = t4.id
这句话怎么理解:求表d中num1和num2分别符合一个条件的个数是不是把(select distinct p_name from a)来替换p_name?select distinct t3.id, t3.name
from a t3,
(select t1.id
from (select a.id, count(c.b_id) c_count
from a, c
where a.id = c.a_id
group by a.id) t1,
(select a.id, count(d.a_id) d_count
from a, d
where a.id = d.a_id
and d.num1 = 'tiaojian1'
and d.num2 = 'tiaojian2'
group by a.id) t2
where t1.id = t2.id
and t1.c_count = t2.d_count) t4
where t3.id = t4.id
如果我那样替换掉可以吗?
这句话怎么理解:求表d中num1和num2分别符合一个条件的个数是不是把(select distinct p_name from a)来替换p_name?select distinct t3.id, t3.name
from a t3,
(select t1.id
from (select a.id, count(c.b_id) c_count
from a, c
where a.id = c.a_id
group by a.id) t1,
(select a.id, count(d.a_id) d_count
from a, d
where a.id = d.a_id
and d.num1 = 'tiaojian1'
and d.num2 = 'tiaojian2'
group by a.id) t2
where t1.id = t2.id
and t1.c_count = t2.d_count) t4
where t3.id = t4.id
如果我那样替换掉可以吗?
你那个条件没有意义啊,你那样求出全部A表中name,然后再和a表中的name作等值比较,那么这个条件不就是一个恒等式吗?
无论如何都满足啊,这样的条件没有意义啊
这句话怎么理解:求表d中num1和num2分别符合一个条件的个数是不是把(select distinct p_name from a)来替换p_name?select distinct t3.id, t3.name
from a t3,
(select t1.id
from (select a.id, count(c.b_id) c_count
from a, c
where a.id = c.a_id
group by a.id) t1,
(select a.id, count(d.a_id) d_count
from a, d
where a.id = d.a_id
and d.num1 = 'tiaojian1'
and d.num2 = 'tiaojian2'
group by a.id) t2
where t1.id = t2.id
and t1.c_count = t2.d_count) t4
where t3.id = t4.id
如果我那样替换掉可以吗?
你那个条件没有意义啊,你那样求出全部A表中name,然后再和a表中的name作等值比较,那么这个条件不就是一个恒等式吗?
无论如何都满足啊,这样的条件没有意义啊还记的《繁琐子查询》那个帖子么?
如果那个帖子中的p_name也是这样得来的话。那个sql语句又要怎么去写。求指点!
这句话怎么理解:求表d中num1和num2分别符合一个条件的个数是不是把(select distinct p_name from a)来替换p_name?select distinct t3.id, t3.name
from a t3,
(select t1.id
from (select a.id, count(c.b_id) c_count
from a, c
where a.id = c.a_id
group by a.id) t1,
(select a.id, count(d.a_id) d_count
from a, d
where a.id = d.a_id
and d.num1 = 'tiaojian1'
and d.num2 = 'tiaojian2'
group by a.id) t2
where t1.id = t2.id
and t1.c_count = t2.d_count) t4
where t3.id = t4.id
如果我那样替换掉可以吗?
你那个条件没有意义啊,你那样求出全部A表中name,然后再和a表中的name作等值比较,那么这个条件不就是一个恒等式吗?
无论如何都满足啊,这样的条件没有意义啊http://bbs.csdn.net/topics/390844309
这句话怎么理解:求表d中num1和num2分别符合一个条件的个数是不是把(select distinct p_name from a)来替换p_name?select distinct t3.id, t3.name
from a t3,
(select t1.id
from (select a.id, count(c.b_id) c_count
from a, c
where a.id = c.a_id
group by a.id) t1,
(select a.id, count(d.a_id) d_count
from a, d
where a.id = d.a_id
and d.num1 = 'tiaojian1'
and d.num2 = 'tiaojian2'
group by a.id) t2
where t1.id = t2.id
and t1.c_count = t2.d_count) t4
where t3.id = t4.id
如果我那样替换掉可以吗?
你那个条件没有意义啊,你那样求出全部A表中name,然后再和a表中的name作等值比较,那么这个条件不就是一个恒等式吗?
无论如何都满足啊,这样的条件没有意义啊http://bbs.csdn.net/topics/390844309
对的,这个也是我帮你写的,那里的pname也是一个你需要指定的条件,比如:如果你需要查'zhangsan'的数据,那么你就将pname换成‘zhangsan’
这句话怎么理解:求表d中num1和num2分别符合一个条件的个数是不是把(select distinct p_name from a)来替换p_name?select distinct t3.id, t3.name
from a t3,
(select t1.id
from (select a.id, count(c.b_id) c_count
from a, c
where a.id = c.a_id
group by a.id) t1,
(select a.id, count(d.a_id) d_count
from a, d
where a.id = d.a_id
and d.num1 = 'tiaojian1'
and d.num2 = 'tiaojian2'
group by a.id) t2
where t1.id = t2.id
and t1.c_count = t2.d_count) t4
where t3.id = t4.id
如果我那样替换掉可以吗?
你那个条件没有意义啊,你那样求出全部A表中name,然后再和a表中的name作等值比较,那么这个条件不就是一个恒等式吗?
无论如何都满足啊,这样的条件没有意义啊http://bbs.csdn.net/topics/390844309
对的,这个也是我帮你写的,那里的pname也是一个你需要指定的条件,比如:如果你需要查'zhangsan'的数据,那么你就将pname换成‘zhangsan’
如果那个p_name:跟这个p_name 的来源一样业务一样呢?
也就是说那个p_name和这个p_name是同一个,
同样来源于表a,也是去看a表中每一个name。
这句话怎么理解:求表d中num1和num2分别符合一个条件的个数是不是把(select distinct p_name from a)来替换p_name?select distinct t3.id, t3.name
from a t3,
(select t1.id
from (select a.id, count(c.b_id) c_count
from a, c
where a.id = c.a_id
group by a.id) t1,
(select a.id, count(d.a_id) d_count
from a, d
where a.id = d.a_id
and d.num1 = 'tiaojian1'
and d.num2 = 'tiaojian2'
group by a.id) t2
where t1.id = t2.id
and t1.c_count = t2.d_count) t4
where t3.id = t4.id
如果我那样替换掉可以吗?
你那个条件没有意义啊,你那样求出全部A表中name,然后再和a表中的name作等值比较,那么这个条件不就是一个恒等式吗?
无论如何都满足啊,这样的条件没有意义啊http://bbs.csdn.net/topics/390844309
对的,这个也是我帮你写的,那里的pname也是一个你需要指定的条件,比如:如果你需要查'zhangsan'的数据,那么你就将pname换成‘zhangsan’
如果那个p_name:跟这个p_name 的来源一样业务一样呢?
也就是说那个p_name和这个p_name是同一个,
同样来源于表a,也是去看a表中每一个name。
select t1.a_id, t4.name, t1.s1 - t2.s2
from (select a.a_id, sum(b.b_area) s1
from a, b, c
where a.a_id = c.a_id
and c.b_id = b.id
group by a.a_id) t1,
(select a.a_id, sum(d.d_area) s2
from a, d
where a.a_id = d.a_id
group by a.a_id) t2,
(select value from e where e.valname = 'test') t3,
a t4
where t1.a_id = t2.a_id
and t1.a_id = t4.a_id
and t1.s1 - t2.s2 < t3.value
这句话怎么理解:求表d中num1和num2分别符合一个条件的个数是不是把(select distinct p_name from a)来替换p_name?select distinct t3.id, t3.name
from a t3,
(select t1.id
from (select a.id, count(c.b_id) c_count
from a, c
where a.id = c.a_id
group by a.id) t1,
(select a.id, count(d.a_id) d_count
from a, d
where a.id = d.a_id
and d.num1 = 'tiaojian1'
and d.num2 = 'tiaojian2'
group by a.id) t2
where t1.id = t2.id
and t1.c_count = t2.d_count) t4
where t3.id = t4.id
如果我那样替换掉可以吗?
你那个条件没有意义啊,你那样求出全部A表中name,然后再和a表中的name作等值比较,那么这个条件不就是一个恒等式吗?
无论如何都满足啊,这样的条件没有意义啊http://bbs.csdn.net/topics/390844309
对的,这个也是我帮你写的,那里的pname也是一个你需要指定的条件,比如:如果你需要查'zhangsan'的数据,那么你就将pname换成‘zhangsan’
如果那个p_name:跟这个p_name 的来源一样业务一样呢?
也就是说那个p_name和这个p_name是同一个,
同样来源于表a,也是去看a表中每一个name。
select t1.a_id, t4.name, t1.s1 - t2.s2
from (select a.a_id, sum(b.b_area) s1
from a, b, c
where a.a_id = c.a_id
and c.b_id = b.id
group by a.a_id) t1,
(select a.a_id, sum(d.d_area) s2
from a, d
where a.a_id = d.a_id
group by a.a_id) t2,
(select value from e where e.valname = 'test') t3,
a t4
where t1.a_id = t2.a_id
and t1.a_id = t4.a_id
and t1.s1 - t2.s2 < t3.value为什么没有那个name的条件了?
这句话怎么理解:求表d中num1和num2分别符合一个条件的个数是不是把(select distinct p_name from a)来替换p_name?select distinct t3.id, t3.name
from a t3,
(select t1.id
from (select a.id, count(c.b_id) c_count
from a, c
where a.id = c.a_id
group by a.id) t1,
(select a.id, count(d.a_id) d_count
from a, d
where a.id = d.a_id
and d.num1 = 'tiaojian1'
and d.num2 = 'tiaojian2'
group by a.id) t2
where t1.id = t2.id
and t1.c_count = t2.d_count) t4
where t3.id = t4.id
如果我那样替换掉可以吗?
你那个条件没有意义啊,你那样求出全部A表中name,然后再和a表中的name作等值比较,那么这个条件不就是一个恒等式吗?
无论如何都满足啊,这样的条件没有意义啊http://bbs.csdn.net/topics/390844309
对的,这个也是我帮你写的,那里的pname也是一个你需要指定的条件,比如:如果你需要查'zhangsan'的数据,那么你就将pname换成‘zhangsan’
如果那个p_name:跟这个p_name 的来源一样业务一样呢?
也就是说那个p_name和这个p_name是同一个,
同样来源于表a,也是去看a表中每一个name。
select t1.a_id, t4.name, t1.s1 - t2.s2
from (select a.a_id, sum(b.b_area) s1
from a, b, c
where a.a_id = c.a_id
and c.b_id = b.id
group by a.a_id) t1,
(select a.a_id, sum(d.d_area) s2
from a, d
where a.a_id = d.a_id
group by a.a_id) t2,
(select value from e where e.valname = 'test') t3,
a t4
where t1.a_id = t2.a_id
and t1.a_id = t4.a_id
and t1.s1 - t2.s2 < t3.value为什么没有那个name的条件了?
你不是要和这个需求一样吗?
这句话怎么理解:求表d中num1和num2分别符合一个条件的个数是不是把(select distinct p_name from a)来替换p_name?select distinct t3.id, t3.name
from a t3,
(select t1.id
from (select a.id, count(c.b_id) c_count
from a, c
where a.id = c.a_id
group by a.id) t1,
(select a.id, count(d.a_id) d_count
from a, d
where a.id = d.a_id
and d.num1 = 'tiaojian1'
and d.num2 = 'tiaojian2'
group by a.id) t2
where t1.id = t2.id
and t1.c_count = t2.d_count) t4
where t3.id = t4.id
如果我那样替换掉可以吗?
你那个条件没有意义啊,你那样求出全部A表中name,然后再和a表中的name作等值比较,那么这个条件不就是一个恒等式吗?
无论如何都满足啊,这样的条件没有意义啊http://bbs.csdn.net/topics/390844309
对的,这个也是我帮你写的,那里的pname也是一个你需要指定的条件,比如:如果你需要查'zhangsan'的数据,那么你就将pname换成‘zhangsan’
如果那个p_name:跟这个p_name 的来源一样业务一样呢?
也就是说那个p_name和这个p_name是同一个,
同样来源于表a,也是去看a表中每一个name。
select t1.a_id, t4.name, t1.s1 - t2.s2
from (select a.a_id, sum(b.b_area) s1
from a, b, c
where a.a_id = c.a_id
and c.b_id = b.id
group by a.a_id) t1,
(select a.a_id, sum(d.d_area) s2
from a, d
where a.a_id = d.a_id
group by a.a_id) t2,
(select value from e where e.valname = 'test') t3,
a t4
where t1.a_id = t2.a_id
and t1.a_id = t4.a_id
and t1.s1 - t2.s2 < t3.value为什么没有那个name的条件了?
你不是要和这个需求一样吗?OK