Here is the code for the inserts and the last subquery problem
Begin tran
Insert into Customer(CustLastName, CustFirstName, CustAddress, CustCity, CustState, CustZipcode, CustPhone)
Values ('Bateman', 'Py', '1000 Somewhere Street', 'Seattle', 'WA', '98122','2065551245')
Declare @Custid int
Set @CustID=@@identity
Insert into Subscription (CustID, MagDetID, SubscriptionStart, SubscriptionEnd)
Values(@custID, 16, '2/1/2010', dateAdd("yy",3, '1/1/2010'))
Commit tran
Create table Contact
(
Firstname varchar(25),
Lastname varchar(30),
Phone char(10)
)
Insert into Contact(Firstname, LastName, Phone)
(Select CustFirstName, CustLastName, CustPhone from Customer)
Select * from Contact
Select * from Customer
Select * from Subscription
Select * from Magazine
Select * From MagazineDetail
Select * from SubscriptionType
Begin tran
Update Contact
Set Lastname='Smith',
FirstName='Joe'
Where Firstname='Steve'
And lastname='Conger'
Select * from MagazineDetail
Update MagazineDetail
Set subscriptionPrice = subscriptionPrice *1.1
Select * from Contact
rollback tran
Begin tran
Delete from Contact
Where Firstname='Steve'
and Lastname='conger'
Delete from Customer
Where Custid=1
Select month(DonationDate) as "Month",
sum(donationAmount) as "Monthly",
(Select Sum(donationAmount) from Donation) as "Total",
(sum(DonationAmount) / (Select Sum(donationAmount) from Donation))*100 as "Percent"
From Donation
Group By month (donationDate)
No comments:
Post a Comment