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?

1 Answers1

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.

Alex Poole
  • 183,384
  • 11
  • 179
  • 318