Quote:
Originally posted by andrewst
When you use aggregate functions like COUNT together with other columns, you have to add a GROUP BY clause to the query. For example, this doesn't work:
Code:
SQL> select deptno, count(*)
2 from emp
3 /
select deptno, count(*)
*
ERROR at line 1:
ORA-00937: not a single-group group function
But this does:
Code:
SQL> select deptno, count(*)
2 from emp
3 group by deptno;
DEPTNO COUNT(*)
---------- ----------
10 3
20 5
30 6
I don't understand what your query is trying to do. Perhaps if you explain the requirement, we can advise on the proper syntax.
|
I want to know how many dvd or vhs for a specific film I have into a particular negozio.
The total number of films that I have into my negozio is contained on the table magazzino ,I have to count the total number of films that are out of my negozio ,counting reservations and rents which are in the table "prenotazione" e "noleggio" for that film in that negozio for that types of support.
do you understand?thank you elisa and my english teacher elena
Table:
CREATE TABLE Magazzino
(CodFilm NUMBER(7) NOT NULL,
CodNegozio NUMBER(8) NOT NULL,
Tipo VARCHAR2(3) NOT NULL,
Quantità NUMBER(4) NOT NULL,
Evetuali_Commenti VARCHAR2(30),
PRIMARY KEY(CodFilm,CodNegozio,Tipo)
FOREIGN KEY(CodNegozio)
REFERENCES Negozio(IdNegozio)
ON DELETE CASCADE,
FOREIGN KEY(CodFilm)
REFERENCES Film(IdFilm)
ON DELETE CASCADE)
CREATE TABLE Prenotazione
(CodFilm NUMBER(7) NOT NULL,
CodNegozio NUMBER(8) NOT NULL,
CodCliente VARCHAR(10) NOT NULL,
Data_Prenotazione NUMBER(8) NOT NULL,
Ora_Prenotazione NUMBER(5) NOT NULL,
Data_Scadenza_Prenotazione NUMBER(8) NOT NULL,
Ora_Scadenza_Prenotazione NUMBER(5) NOT NULL,
Supporto VARCHAR2(3) NOT NULL,
PRIMARY KEY(CodFilm,CodNegozio,CodCliente,Data_Prenotazion e,Ora_Prenotazione,Supporto)
FOREIGN KEY(CodNegozio)
REFERENCES Negozio(IdNegozio)
ON DELETE CASCADE,
FOREIGN KEY(CodFilm)
REFERENCES Film(IdFilm)
ON DELETE CASCADE,
FOREIGN KEY(CodCliente)
REFERENCES Cliente(User_id)
ON DELETE CASCADE)
CREATE TABLE Noleggio
(CodFilm NUMBER(7) NOT NULL,
CodNegozio NUMBER(8) NOT NULL,
CodCliente VARCHAR(10) NOT NULL,
Data_Noleggio NUMBER(8) NOT NULL,
Ora_Noleggio NUMBER(5) NOT NULL,
Supporto VARCHAR2(3) NOT NULL,
PRIMARY KEY (CodFilm,CodNegozio,CodCliente,Data_noleggio,Ora_N oleggio,Supporto)
FOREIGN KEY(CodNegozio)
REFERENCES Negozio(IdNegozio)
ON DELETE CASCADE,
FOREIGN KEY(CodFilm)
REFERENCES Film(IdFilm)
ON DELETE CASCADE,
FOREIGN KEY(CodCliente)
REFERNCES Cliente(User_id)
ON DELETE CASCADE)