Share
Explore BrainMass

SQL Sample Database Queries

I am seeking help with solving several SQL statements. I am specifically looking for the code that goes with these problems.

6) A wide world importers company tracks its order information in a database that includes two tables: Order and LineItem. See table structures below:

CREATE TABLE dbo.Order (
OrderID int NOT NULL,
CustomerID int NOT NULL,
OrderDate datetime NOT NULL,
CONSTRAINT DF_Order_OrderDate DEFAULT (getdate())FOR OrderDate,
CONSTRAINT PK_Order PRIMARY KEY CLUSTERED (OrderID)
)
CREATE TABLE dbo.LineITEM (
ItemID int NOT NULL,
OrderID INT NOT NULL,
ProductID int NOT NULL,
Price money NOT NULL,
CONSTRAINT PK_LineITEM PRIMARY KEY CLUSTERED (ItemID),
CONSTRAINT FK_LineITEM_Order FOREIGN KEY (OrderID)
REFERENCES dbo.Order (OrderID)
)

The company's auditors have discovered that every item that was ordered on June 1, 2000, was entered with a price that was $10 more than its actual price. You need to correct the data in the database as quickly as possible.

7) A sporting goods company exports products to customers worldwide. The company stores its sales information in a database named sales. Customer names are stored in a table named Customer in this database.

CREATE TABLE customers (
CustmerID int NOT NULL,
CustomerName varchar(30) NOT NULL,
ContactName varchar(30) NULL,
Phone varchar(20) NULL,
Country varchar(30) NOT NULL,
CONSTRAINT PK_Customers PRIMARY KEY (CustomerID)
)

There are usually only one or two customers per country. However, some countries have as many as 20 customers. Your company's marketing department wants to target its advertising to countries that have more than 10 customers. You need to create a list of these countries for the marketing department.

****Feel free to input your own countries for this*****

Attachments

$2.19