菜鸟求教:我建了两个表author和books,数据中一个作者写了两本书,为了不重复出现作者名字于是有了第一个问题的写法,我不明白distinct的用法,于是以第二个问题为例问下。求高手指点!!
第一个问题
select aname,max(age),max(bname),max(press_name)
2 from author,books
3 where age<(select avg(age) from author)
4 and author.a_id=books.author_id group by aname
其中bname是书名,press-name是出版社名,我不明白max的作用?单纯为了能够使用group by吗?
第二个问题
select distinct aname,age,bname,press_name
2 from author,books
3 where age<(select avg(age) from author)
4 and author.a_id=books.author_id;
这里面distinct是不是只有aname、age、bname和pressname的内容都用重复的时候才能将两个数据一起显示?
第一个问题
select aname,max(age),max(bname),max(press_name)
2 from author,books
3 where age<(select avg(age) from author)
4 and author.a_id=books.author_id group by aname
其中bname是书名,press-name是出版社名,我不明白max的作用?单纯为了能够使用group by吗?
第二个问题
select distinct aname,age,bname,press_name
2 from author,books
3 where age<(select avg(age) from author)
4 and author.a_id=books.author_id;
这里面distinct是不是只有aname、age、bname和pressname的内容都用重复的时候才能将两个数据一起显示?
解决方案 »
- 如何查询对表结构进行操作的日志
- 关于日期类型的模糊查询问题
- 这个简单的触发器为什么报错?
- 查询最小值的弱问题
- 关于LINUX下编译OTL出现的OCI.H找不到的问题
- 如何用批处理在Orcal 10g中创建表空间和数据(急急急急急急急急急急急急急急)
- 如何给用户赋 update一个字段的权限?
- 版主好,占用一点空间,希望大家看到,学校暴力!
- 高分求助:ORA-01795 maximum number of expressions in a list is 1000
- oracle 逐行计算(总价 = 单价*数量)
- system和sys用户有什么区别?还有system 作为sysdba登陆后此时和sys又有什么区别?
- sql查询的问题(a or b加a and b加ab)?
2、distinct过滤掉所有字段都重复的数据。distinct aname,age,bname,press_name 当三个字段不重复的时候数据才显示
而是为了符合基本的语法