user3586248
user3586248

Reputation: 163

Oracle SQL Insert Single Row Subquery returns more than one row

I am trying to run the following query in Oracle SQL, but it keeps returing an error that 'single row subquery returns more than one row'. The query for DESCR254 grabs 10 results.

INSERT INTO PS_Z_TREND_NOW_TBL 
  VALUES(
 (SELECT DESCR254 
  FROM ( 
 SELECT DESCR254
 , COUNT(*) AS COUNT 
  FROM PS_IS_STATS_URLS 
  GROUP BY DESCR254 
  ORDER BY COUNT(*) DESC, DESCR254 ) 
 WHERE ROWNUM <= 10), ' ')

The PS_Z_TREND_NOW_TBL has two columns. I am trying to insert the results of the subquery in the first column and just add ' ' in the second column. Does anyone know what I'm doing wrong?

Upvotes: 0

Views: 607

Answers (1)

neshkeev
neshkeev

Reputation: 6476

Try this:

INSERT INTO PS_Z_TREND_NOW_TBL 
SELECT DESCR254,' '
  FROM ( 
 SELECT DESCR254
      , COUNT(*) AS COUNT 
   FROM PS_IS_STATS_URLS 
  GROUP BY DESCR254 
  ORDER BY COUNT(*) DESC, DESCR254
  ) 
 WHERE ROWNUM <= 10))

Upvotes: 1

Related Questions