Here is the SQL we did in class with CommunityAssist::
Use CommunityAssist
/*******************
script from 2/23/2010
********************/
Select Lastname, firstname
From Person
Select * From Person
--this only returns unique values
Select Distinct PersonKey from Donation
Order by PersonKey Desc
Select DonationAmount, DonationAmount * .9 As [to Charity]
From Donation
Select * From PersonAddress
Where Not City='Seattle'
Select *
from PersonAddress
Where Apartment
is not Null
Select * from Employee
Where Hiredate > '1/1/2003'
Select * from Employee
Where Dependents >2
Select top 3 Lastname from Person
Order by LastName
Select LastName from Person
Where Lastname LIKE '_a%'
--aggregate functions
Select Count(*) from Donation
Select sum(DonationAmount) From Donation
Select Max(DonationAmount) from Donation
Select MIN(DonationAmount) from Donation
Select Round(Avg(DonationAmount),2)
from Donation
Select Month(DonationDate) as [Month],
Sum(DonationAmount) as Total
From Donation
Group by Month(DonationDate)
Select EmployeeKey,
Sum(DonationAmount) as Total
From Donation
Group by EmployeeKey
No comments:
Post a Comment