Tuesday, February 26, 2013

SQL 1

use CommunityAssist

Select PersonKey, FirstName,LastName from Person
Select * From Person

Select LastName, Firstname From Person
order by Lastname Desc


Select LastName, Firstname From Person
order by Lastname Desc, FirstName DESC

Select Distinct PersonKey From Donation 
order by PersonKey

Select LastName as [Last Name], 
 FirstName as [First Name]
From Person

Select 5 * 2 + 4 /3.0

Select DonationAmount, Cast(DonationAmount * .15 as Decimal(6,2))[Maintainance], DonationAmount * .85 [To charity]
From Donation

Select * From PersonAddress

Select * From PersonAddress
where City = 'Seattle'

Select * From PersonAddress
where City = 'Kent'

Select * From Donation
Where DonationAmount >= 2500

Select * From Donation
Where DonationAmount < 2500

Select * from PersonAddress 
Where not city = 'Seattle'

Select * from PersonAddress 
Where city != 'Seattle'

Select * From Person
Where lastname like 'Mo%'

Select * From PersonAddress
where street like '%ave%'

Select * From Donation
where DonationDate between '3/1/2010' and '3/15/2010'

Select * From Donation
where DonationDate >= '3/1/2010' 
and  DonationDate <= '3/15/2010'

Select * from PersonAddress where apartment is null

Select * from PersonAddress where apartment is not null
and Apartment like '%suite%'


No comments:

Post a Comment