[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[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!

8.9

How can I get the headings and columns to line up properly?

Asked by geeta_m9 in Oracle Database

Tags: SQL

I would like to output my column headings and data neatly, with one or two spacings apart between columns, all on one line, if possible. My problem is that I can't seem to get the headings and the columns to line up properly. I have to mess with spaces to try to get them to line up. It is very frustrating. I would greatly appreciate it if someone could help me with this. The widths of my columns are as follows"
 
SWRREQD_SBGI_CODE              NOT NULL VARCHAR2(6 CHAR)          
SWRREQD_ACYR_CODE              NOT NULL VARCHAR2(4 CHAR)  
SWVSBGI_DESC                          NOT NULL VARCHAR2(60 CHAR)                                                                                                                                                                
SWRREQD_DEGT_TRNS              NOT NULL VARCHAR2(6 CHAR)          
SWVDEGT_DESC                   NOT NULL VARCHAR2(100 CHAR                                                                                                                                                                  
SWRREQD_DEGC_INST              NOT NULL VARCHAR2(6 CHAR)                                                                                                                                                                              
SWRREQD_MAJR_CODE             NOT NULL VARCHAR2(4 CHAR)        
STVMAJR_DESC                            VARCHAR2(30 CHAR                                                                                                                                                                      
SWRREQD_CONC_CODE            NOT NULL VARCHAR2(4 CHAR)                                                                                                                                                                              
SWRREQD_SEQNO                     NOT NULL NUMBER(3,1)                                                                                                                                                                                  
SWRREQD_SUBJ_CODE              NOT NULL VARCHAR2(60 CHAR)                                                                                                                                                                            
SWRREQD_CRSE_NUMB             NOT NULL VARCHAR2(60 CHAR)                                                                                                                                                                            
                                                                                                                                                                                                                                                                                                                                                                                                                                           
SWRREQD_COUNTER                NOT NULL NUMBER(3,1)      
Count(*)                                                                                                                                                                                                                
                                                                                                                                                                                         
Eventhough the description (DESC) columns are of length 60 or 100, I only really need the first 40 characters because the rest all a blank. The SUBJ_CODE and CRSE_NUMB columns are shown of length 60,  but in reality they only take up 5 characters. I attempted to write my code as shown below, but I have had to put in leading blanks before the column titles to try to get them to line up. I know there should be a better way.
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:
26:
27:
28:
29:
set linesize 200;
set pagesize 100;
set underline off;
column Inst_Code heading "Code" format a4;
column Catalog_Year heading "Year" format a4;
column Inst_Desc heading "Inst Desc" format a20;
column Deg_Trns heading "Deg Trns" format a10;
column Deg_Trns_Desc heading "  Degree Desc" format a40;
--column Deg_Inst heading "              Deg Inst" format a22;
--column Deg_Inst_Desc heading "              Deg Desc" format a22;
--column Major_Code heading "          Major Code" format a20;
--column Major_Desc heading "        Major Desc" format a25;
--column Conc heading "Conc" format a4;
--column Seq_No heading "        Seq No" format x;
--column Subj_Code heading "Subj Code" format a9;
--column Course_No heading "Course Num" format a6;
--column Count heading "Count" format 99;
 
SELECT SWRREQD_SBGI_CODE Inst_Code, SWRREQD_ACYR_CODE Catalog_Year, SWVSBGI_DESC Inst_Desc, TRIM(SWRREQD_DEGT_TRNS) Deg_Trns, TRIM(SWVDEGT_DESC) Deg_Trns_Desc, 
TRIM(SWRREQD_DEGC_INST) Deg_Inst, TRIM(STVDEGC_DESC) Deg_Inst_Desc, TRIM(SWRREQD_MAJR_CODE) Major_Code, TRIM(STVMAJR_DESC) Major_Desc, 
SWRREQD_CONC_CODE Conc, SWRREQD_SEQNO Seq_No, TRIM(SWRREQD_SUBJ_CODE) Subj_Code, SWRREQD_CRSE_NUMB Course_No, 
 COUNT (*) Count
FROM SWRREQD, SWVSBGI, SWVDEGT, STVMAJR, STVDEGC
WHERE SWRREQD_SBGI_CODE = SWVSBGI_CODE AND SWRREQD_MAJR_CODE = STVMAJR_CODE AND SWRREQD_DEGT_TRNS = SWVDEGT_CODE 
AND SWRREQD_DEGC_INST = STVDEGC_CODE
GROUP BY SWRREQD_SBGI_CODE, SWVSBGI_DESC, SWRREQD_DEGT_TRNS, SWVDEGT_DESC, SWRREQD_DEGC_INST, STVDEGC_DESC, SWRREQD_MAJR_CODE, 
STVMAJR_DESC, SWRREQD_CONC_CODE, SWRREQD_SEQNO, SWRREQD_SUBJ_CODE, SWRREQD_CRSE_NUMB, SWRREQD_ACYR_CODE
HAVING COUNT(*) > 1
ORDER BY SWRREQD_SBGI_CODE, SWRREQD_DEGT_TRNS, SWRREQD_DEGC_INST, SWRREQD_MAJR_CODE;
[+][-]09/30/09 02:15 PM, ID: 25463726Accepted Solution

View this solution now by starting your 30-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

Zone: Oracle Database
Tags: SQL
Sign Up Now!
Solution Provided By: paquicuba
Participating Experts: 3
Solution Grade: B
 
[+][-]09/30/09 01:43 PM, ID: 25463386Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10/01/09 12:22 AM, ID: 25466544Assisted Solution

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]10/01/09 08:35 AM, ID: 25469826Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/01/09 08:36 AM, ID: 25469838Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10/01/09 02:40 PM, ID: 25473455Assisted Solution

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]10/02/09 09:03 AM, ID: 25479206Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091118-EE-VQP-93 - Hierarchy / EE_QW_3_20080625