Hi all !
I 'm a newbie in SQL and has just install the Oracle 10g Express Edition. When using its SQL Command in the Web-interface, I took an error with the GROUP BY, as follow :
First, I create a table DEPARTMENT, here 's the code :
CREATE TABLE DEPARTMENT ( Dname VARCHAR(15) NOT NULL, Dnumber INT NOT NULL, Mgr_ssn CHAR(9) NOT NULL, Mgr_start_date DATE, PRIMARY KEY(Dnumber), UNIQUE(Dname) --FOREIGN KEY(Mgr_ssn) REFERENCES EMPLOYEE(Ssn) );
Then I insert some values into it, using the "INSERT INTO ... VALUES ... " statement, here 's my result :
DNAME DNUMBER MGR_SSN MGR_START_DATE
Research 5 333445555 22-MAY-88
Administration 4 987654321 01-JAN-95
Headquarters 1 888665555 19-JUN-81
When I try
select Dname from DEPARTMENT GROUP BY Dname;
It goes perfectly and I get :
But when I use
select Dname, Dnumber from DEPARTMENT GROUP BY Dname;
I took a "ORA-00979: not a GROUP BY expression" error ... ?
I try a similar one
select Dname, Dnumber from DEPARTMENT GROUP BY Dname, Dnumber;
and get good result :
But in this case, I have no sense about how it work ... ?
Please explain me ... :confused: Thank U very much ! ^^