由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Database版 - PIVOT TABLE
相关主题
问一个SQL Server的问题SQL add some columns into a table from another table (转载
求教个MS SQL的问题问个SQL问题
help about SQL for ACCESSPIVOT question
better solution for cross table query in sql?请问一个SQL语句的优化问题
急问一个关于T-SQL的问题,谢谢请教一个SQL Query
SQL combine two columns from two different tables no shared (转载)SQL question
[转载] what's wrong with this PL/SQL我也问一个sql querry的问题
To get the 2nd, 3rd, 4th largest value请教oracle select top 10 from ... order by desc
相关话题的讨论汇总
话题: degree话题: pivot话题: select话题: educ话题: level
进入Database版参与讨论
1 (共1页)
r****5
发帖数: 618
1
select degree_level,year_earned,educ_code,degree_title,emp_num
from education
join degree using(educ_code)
pivot(
count(degree_level)
FOR year_earned IN ('1992,1993,1994,1995,1999,2001,2003')
);
Fails after running. ORA-00933: SQL command not properly ended
Any suggestions?
B*****g
发帖数: 34098
2
WITH combined AS
(SELECT degree_level,
year_earned,
educ_code,
degree_title,
emp_num
FROM education JOIN degree USING (educ_code))
SELECT *
FROM combined PIVOT (COUNT (degree_level)
FOR year_earned
IN ('1992', '1993', '1994', '1995', '1999', '2001', '2003'
))

【在 r****5 的大作中提到】
: select degree_level,year_earned,educ_code,degree_title,emp_num
: from education
: join degree using(educ_code)
: pivot(
: count(degree_level)
: FOR year_earned IN ('1992,1993,1994,1995,1999,2001,2003')
: );
: Fails after running. ORA-00933: SQL command not properly ended
: Any suggestions?

z**********8
发帖数: 2049
3
SELECT degree_level AS Number of degree level,
[1992], [1993], [1994], [1995], [1999], [2001], [2003]
FROM combined PIVOT (COUNT (degree_level)
FOR year_earned
IN ( [1992], [1993], [1994], [1995], [1999], [2001], [2003]
))
please correct it.
r****5
发帖数: 618
4
Beijing,
Many thanks, but I run the script and still got the following error message
ORA-00933: SQL command not properly ended
The first part works ok, just the second one "SELECT *..." does not work.
What is wrong with my original one?
Thanks again.

【在 B*****g 的大作中提到】
: WITH combined AS
: (SELECT degree_level,
: year_earned,
: educ_code,
: degree_title,
: emp_num
: FROM education JOIN degree USING (educ_code))
: SELECT *
: FROM combined PIVOT (COUNT (degree_level)
: FOR year_earned

B*****g
发帖数: 34098
5
你oracle什么版本?

message

【在 r****5 的大作中提到】
: Beijing,
: Many thanks, but I run the script and still got the following error message
: ORA-00933: SQL command not properly ended
: The first part works ok, just the second one "SELECT *..." does not work.
: What is wrong with my original one?
: Thanks again.

1 (共1页)
进入Database版参与讨论
相关主题
请教oracle select top 10 from ... order by desc急问一个关于T-SQL的问题,谢谢
外行请教一个简单的SQL: 养宠物罚款SQL combine two columns from two different tables no shared (转载)
请帮我看看,什么地方错了?[转载] what's wrong with this PL/SQL
请教SQL server的一个programming的问题,谢谢To get the 2nd, 3rd, 4th largest value
问一个SQL Server的问题SQL add some columns into a table from another table (转载
求教个MS SQL的问题问个SQL问题
help about SQL for ACCESSPIVOT question
better solution for cross table query in sql?请问一个SQL语句的优化问题
相关话题的讨论汇总
话题: degree话题: pivot话题: select话题: educ话题: level