Question

Locked

SQL help required.

By mckevitt ·
could someone kindly help me out with the following.

The following query works fine however i need to do the same thing only this time using an explicit join.

select Departments.Deptnumber, Departments.name,
sum (quantity)
from SalesOrderItems, Departments
where Departments.Deptnumber = SalesOrderItems.DeptNumber
group by Departments.Deptnumber, Departments.name;


I have tried

select Departments.Deptnumber, Departments.name,
sum (quantity)
from Departments INNER JOIN SalesOrderItems
ON Departments.Deptnumber = SalesOrderItems.DeptNumber
order by Departments.Deptnumber, Departments.name;

but keep getting the error
ERROR at line 3:
ORA-00933: SQL command not properly ended

any help will be apriciated thanks.

This conversation is currently closed to new comments.

2 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Answers

Collapse -

Not properly ended means

by robo_dev In reply to SQL help required.

your 'order by' clause is not understood.

What version Oracle?

Joins are not supported in versions prior to 9i

Collapse -

Still need group by for sum operator

by Tony Hopkinson In reply to SQL help required.

select Departments.Deptnumber, Departments.name,
sum (SalesOrderItems.Quantity)
from Departments
inner join SalesOrderItems
On Departments.Deptnumber = SalesOrderItems.DeptNumber
group by Departments.Deptnumber, Departments.name

Group By should give you the ordering as well me thinks.

Back to Web Development Forum
2 total posts (Page 1 of 1)  

Related Discussions

Related Forums