由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Database版 - 新手问个简单的SELECT问题
相关主题
To get the 2nd, 3rd, 4th largest value再现急求答案,多谢。
help about SQL for ACCESS也来问个SQL的问题
问个sql问题问一个Oralce index的问题
请问这两个SQL QUERY有什么错?[合集] 问一个Oralce index的问题
correlated subquery新手学数据库一个简单题求助
[转载] what's wrong with this PL/SQLaks a simple SQL question
help needed问个SQL问题
求求!waiting online问个SQL问题- partial outer join
相关话题的讨论汇总
话题: name话题: employees话题: group话题: 00937
进入Database版参与讨论
1 (共1页)
w*********n
发帖数: 439
1
问:Create a report that shows the name, location, and number of employees
for each department. Make sure that the report also includes departments
without employees.
答:
select DISTINCT e.first_name, e.last_name, d.department_name, l.street_
address, l.city, l.state_province, c.COUNTRY_NAME
count(*) AS "number of employees"
from departments d, employees e, LOCATIONS l, COUNTRIES c
where d.department_id = e.department_id AND d.LOCATION_ID = l.LOCATION_ID
AND l.COUNTRY_ID = c.COUNTRY_ID
order by d.department_name;
运行以后出错了。
-----------------------------------------------
ORA-00937: not a single-group group function
00937. 00000 - "not a single-group group function"
*Cause:
*Action:
Error at Line: 17 Column: 9
s**********o
发帖数: 14359
2
大哥您怎么学的啊,考你的关键词都没写出来,你这个考试,写全写对是100
你这个是0分,关键词都没答上来
c*******e
发帖数: 8624
3
LZ是文科大妈?完全不着边啊

【在 s**********o 的大作中提到】
: 大哥您怎么学的啊,考你的关键词都没写出来,你这个考试,写全写对是100
: 你这个是0分,关键词都没答上来

B*****g
发帖数: 34098
4
http://www.w3schools.com/sql/sql_groupby.asp

【在 w*********n 的大作中提到】
: 问:Create a report that shows the name, location, and number of employees
: for each department. Make sure that the report also includes departments
: without employees.
: 答:
: select DISTINCT e.first_name, e.last_name, d.department_name, l.street_
: address, l.city, l.state_province, c.COUNTRY_NAME
: count(*) AS "number of employees"
: from departments d, employees e, LOCATIONS l, COUNTRIES c
: where d.department_id = e.department_id AND d.LOCATION_ID = l.LOCATION_ID
: AND l.COUNTRY_ID = c.COUNTRY_ID

a*****8
发帖数: 2689
5
是这样,还是再看看书吧,看看 骨肉漂白液怎么用。

【在 w*********n 的大作中提到】
: 问:Create a report that shows the name, location, and number of employees
: for each department. Make sure that the report also includes departments
: without employees.
: 答:
: select DISTINCT e.first_name, e.last_name, d.department_name, l.street_
: address, l.city, l.state_province, c.COUNTRY_NAME
: count(*) AS "number of employees"
: from departments d, employees e, LOCATIONS l, COUNTRIES c
: where d.department_id = e.department_id AND d.LOCATION_ID = l.LOCATION_ID
: AND l.COUNTRY_ID = c.COUNTRY_ID

w*********n
发帖数: 439
6
请各位各位大侠指教一下。
怎样才能得到每个department有多少employee?

【在 a*****8 的大作中提到】
: 是这样,还是再看看书吧,看看 骨肉漂白液怎么用。
w*********n
发帖数: 439
7


【在 w*********n 的大作中提到】
: 请各位各位大侠指教一下。
: 怎样才能得到每个department有多少employee?

c*****d
发帖数: 6045
8
如果要得到每个department有多少employee
select d.department_name, count(*)
from employees e, departments d
where e.department_id = d.department_id
group by d.department_name;
如果要得到employee name, location name和每个department有多少employee
必须要用partition或者subquery

【在 w*********n 的大作中提到】
: 请各位各位大侠指教一下。
: 怎样才能得到每个department有多少employee?

1 (共1页)
进入Database版参与讨论
相关主题
问个SQL问题- partial outer joincorrelated subquery
Please Help! ORA-00918: column ambiguously defined[转载] what's wrong with this PL/SQL
问个查询的问题help needed
Get companies providing services求求!waiting online
To get the 2nd, 3rd, 4th largest value再现急求答案,多谢。
help about SQL for ACCESS也来问个SQL的问题
问个sql问题问一个Oralce index的问题
请问这两个SQL QUERY有什么错?[合集] 问一个Oralce index的问题
相关话题的讨论汇总
话题: name话题: employees话题: group话题: 00937