Susana Rodriguez
Susana Rodriguez

Reputation: 23

Oracle Error when creating a Table. ORA-00998: must name this expression with a column alias

Hello I'm not exactly sure why I am getting this error message: ORA-00998: must name this expression with a column alias 00998. 00000 - "must name this expression with a column alias"

Here's my code:

CREATE TABLE test_table_volume1 AS (SELECT t.year,
      t.month,
      soldto,
      t.pickup,
      product_id,
      t.originfacilitycode,
      t.destinationfacilitycode,
      Sum(t.tot_weight),
      Sum(T.tot_billableweight),
      Sum(t.tot_postage),
      Sum(t.cnt_manfst),
      CASE
        WHEN t.markupreasoncode IN ( '20' ) THEN 'NQD'
        ELSE ''
      END AS markupreasoncode 
FROM   ops_owner.volume_summary_month t,
      ops_owner.track_mail_dsp_products a
WHERE  dateselect IN ( 202105 )
      AND t.dsp_id = 101
      AND t.manifesteddspproduct = a.dspproductcode
GROUP  BY t.year,
         t.month,
         soldto,
         t.pickup,
         product_id,
         t.originfacilitycode,
         t.destinationfacilitycode,
         CASE
           WHEN t.markupreasoncode IN ( '20' ) THEN 'NQD'
           ELSE ''
         END);'

Upvotes: 0

Views: 651

Answers (1)

Alistair Wall
Alistair Wall

Reputation: 332

Oracle can automatically generate names for most of the fields, but not for the SUM fields - you will have to supply aliases.

Edit to complement this answer

The columns:

  Sum(t.tot_weight),
  Sum(T.tot_billableweight),
  Sum(t.tot_postage),
  Sum(t.cnt_manfst),

Should have aliases, as in:

  Sum(t.tot_weight) as total_weight,
  Sum(T.tot_billableweight) as total_billable_weight,
  Sum(t.tot_postage) as total_postage,
  Sum(t.cnt_manfst) as total_cnt_manfst,

Upvotes: 2

Related Questions