
CREATE TABLE "Manufacturers" (
	"Code" INTEGER, 
	"Name" VARCHAR(255) NOT NULL, 
	"Headquarter" VARCHAR(255) NOT NULL, 
	"Founder" VARCHAR(255) NOT NULL, 
	"Revenue" REAL, 
	PRIMARY KEY ("Code")
)


CREATE TABLE "Products" (
	"Code" INTEGER, 
	"Name" VARCHAR(255) NOT NULL, 
	"Price" DECIMAL NOT NULL, 
	"Manufacturer" INTEGER NOT NULL, 
	PRIMARY KEY ("Code"), 
	FOREIGN KEY("Manufacturer") REFERENCES "Manufacturers" ("Code")
)

CREATE TABLE "Manufacturers" (
	"Code" INTEGER, 
	"Name" VARCHAR(255) NOT NULL, 
	"Headquarter" VARCHAR(255) NOT NULL, 
	"Founder" VARCHAR(255) NOT NULL, 
	"Revenue" REAL, 
	PRIMARY KEY ("Code")
)

/*
2 rows from Manufacturers table:
Code	Name	Headquarter	Founder	Revenue
1	Sony	Tokyo	Andy	120.0
2	Creative Labs	Austin	Owen	100.0
*/


CREATE TABLE "Products" (
	"Code" INTEGER, 
	"Name" VARCHAR(255) NOT NULL, 
	"Price" DECIMAL NOT NULL, 
	"Manufacturer" INTEGER NOT NULL, 
	PRIMARY KEY ("Code"), 
	FOREIGN KEY("Manufacturer") REFERENCES "Manufacturers" ("Code")
)

/*
2 rows from Products table:
Code	Name	Price	Manufacturer
1	Hard drive	240.0000000000	5
2	Memory	120.0000000000	6
*/
Select the names of manufacturer whose products have an average price higher than or equal to $150.
SELECT avg(T1.Price) ,  T2.name FROM products AS T1 JOIN Manufacturers AS T2 ON T1.manufacturer  =  T2.code GROUP BY T2.name HAVING avg(T1.price) >= 150
[{'avg(T1.Price)': 150.0, 'Name': 'Creative Labs'}, {'avg(T1.Price)': 240.0, 'Name': 'Fujitsu'}, {'avg(T1.Price)': 162.0, 'Name': 'Hewlett-Packard'}, {'avg(T1.Price)': 150.0, 'Name': 'Iomega'}, {'avg(T1.Price)': 240.0, 'Name': 'Sony'}]