Advertisement

11.29.2008 at 11:33AM PST, ID: 23944050
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

6.4

SQL*Plus Report Problem (SQL Statement)

Asked by k_smee in Oracle 10.x, PL / SQL

Tags: ,

Hi Experts,
I am working on a project for my online class and am struggling with a SQL*Plus rpeort. It should be simple, but I don't understand what I am doing wrong.

We have been asked to import a .csv file with 15 fields into an oracle database. I ran SQL*Loader and inserted the records in a table called "employee_personal" We are to write a report in SQL*Plus, as script file (.sql), that shows the native country, occupation and occupation count by country. The end result would look something like:

native_country                 occupation                      count
Vietnam                   Adm-clerical                            12
                               Craft-repair                               23
                               Exec-managerial                       344

Yugoslavia             Craft-repair                              
                               Exec-managerial
                               Machine-op-inspct
                               Other-service
                               Priv-house-serv
I am able to get the "native_country" and "occupation" with the attached code, but I cannot figure oout how to make the COUNT() work. I have tried something like this:

SQL> select distinct native_country, occupation, COUNT(occupation) AS counter  from employee_personal
l
  2  ORDER BY native_country, occupation;
select distinct native_country, occupation, COUNT(occupation) AS counter  from employee_personal
                *
ERROR at line 1:
ORA-00937: not a single-group group function

I get the above error.
Will I have to split this one table to make this work?

I have also attached the .csv file, but I had to save it as .xls so it would upload..

Thanks in advance,

Kevin



Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
rem Occupations Report
 
set headsep !
 
ttitle 'Occupations by Country'
 
column native_country format a30
column occupation format a30
column counter format 999999.99
 
 
break on native_country skip 1 on report
 
set linesize 80
set pagesize 60
set newpage 0
set feedback off
 
spool activity.lst
 
select distinct native_country, occupation  from employee_personal
ORDER BY native_country, occupation;
 
 
spool off
Attachments:
 
File that was loaded via SQL*Loader
 
[+][-]11.29.2008 at 02:11PM PST, ID: 23061051

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Oracle 10.x, PL / SQL
Tags: Oracle, 10g Database
Sign Up Now!
Solution Provided By: k_smee
Participating Experts: 0
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 - Hierarchy / EE_QW_2_20070628