0

I have this minimal example in Oracle DB

create table a (name varchar2(10));
create table b (x number, y number);

and I wish to do this

select (select name from a where rownum <=1), sum(x) from b;

but I get

ORA-00937: not a single-group group function

How can I get the result I want, that is, name from table a and sum from b?

Edit (add example)

Table A

name
=====
foo
bar

Table B

x    y
=======
1    2
10   20

Should give

foo 11
  • Please edit your question and add some sample data and the expected output based on that data. Formatted text please, no screen shots. (edit your question - do not post code or additional information in comments) – a_horse_with_no_name Apr 3 '18 at 11:35
  • The expected result is completely unclear. How are the x values from b related or joined to the name values from a? Or do you simply want a one-row answer with the first name and the sum of all x’s? Please show two small tables as example input and the expected output table. – Dario Apr 3 '18 at 11:35
1
select
  a.name,
  b.sumx
from
  (select name from a where rownum <=1) a,
  (select sum(x) as sumx from b) b
;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.