我有3個sql表:首先我存儲與關鍵PID的產品。第二,我保存帶有關鍵RID的發票。第三張表格用於描述在此發票中每件產品的數量。我需要這兩個問題的幫助,作爲一個很少使用sql的人,這有點難。我怎樣才能得到所需的查詢與這3個表
1)最近3個月購買量最大的產品的查詢量是多少。
2)什麼是查詢將這3種產品的價格提高5%?
DB:
CREATE TABLE Products(
pid INTEGER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
name VARCHAR(30) NOT NULL,
type VARCHAR(8) NOT NULL,
price DOUBLE NOT NULL,
stock INTEGER NOT NULL);
CREATE TABLE Invoices(
rid INTEGER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
invoicedate TIMESTAMP NOT NULL);
CREATE TABLE Orders(
rid INTEGER,
pid INTEGER,
quantity INTEGER NOT NULL,
FOREIGN KEY (pid) REFERENCES Products(pid) ON DELETE CASCADE,
FOREIGN KEY (rid) REFERENCES Invoices(rid) ON DELETE CASCADE);
您使用的是什麼RDBMS? – Lamak 2012-03-21 20:45:11