0

I'm writing an SQL code and running in an SSH secure shell client and here's the output after running the code:

SQL> SELECT SalesRepLName || ' , ' || SalesRepFName AS SalesRep_Name,
  2  SalesRepID AS Sales_Rep_ID, SalesRep.CommClass AS Commission_Class, CommRate AS Commission_Rate
  3   FROM SalesRep_mys SalesRep, Commission_mys Com
  4   WHERE SalesRep.CommClass = Com.CommClass
  5  ORDER BY SalesRepLName;

SALESREP_NAME                               SALES_REP_ID C COMMISSION_RATE
------------------------------------------- ------------ - ---------------
Anderson , Mark                                       21 C             .05
Day , Sara                                            14 Z               0
Hayes , Jennie                                        23 D             .03
Jackson , Bob                                         20 B             .08
Jones , Alice                                         10 A              .1
Moore , Micah                                         22 Z               0
Price , Kay                                            8 C             .05
Taylor , Greg                                         12 B             .08

It's suppose to output the full names like SalesRepID, SalesRep_name, etc..but for the commission class, (the one with letter values) it doesn't print the full category name..? How do fix it so it shows Commission_Class?

3
  • Look here Commented May 10, 2015 at 19:52
  • 1
    You're running this in SQL*Plus, right? Commented May 10, 2015 at 19:52
  • Yeah it's in sqlplus Commented May 10, 2015 at 19:53

1 Answer 1

1

You can override the default column width, which is based on the data type, with the COLUMN command. In this case, before running the query:

column commission_class format a16

More from the documentation::

Character Columns
The default width of CHAR, NCHAR, VARCHAR2 (VARCHAR) and NVARCHAR2 (NCHAR VARYING) columns is the width of the column in the database.
...
To change the width of a datatype to n, use FORMAT An. (A stands for alphabetic.) If you specify a width shorter than the column heading, SQL*Plus truncates the heading.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.