Monday, January 7, 2013

Selects

Use CommunityAssist;
/*
Simple Select examples
1/7/13
*/
Select FirstName, Lastname from Person;
Select * From Person;

Select LastName, FirstName 
From Person
Order by LastName DESC, Firstname ASC --types of sort

--aliasing fields 
Select LastName AS [Last Name],
FirstName as [First Name]
From Person

Select LastName "Last Name",
FirstName "First Name"
From Person

Select LastName Last,
FirstName First 
From Person

Select Distinct PersonKey 
From Donation
Order by PersonKey

Select * From PersonAddress
Where City='Kent'

Select * From PersonAddress
Where City='seattle' or City ='Kent'
Order by City

Select * From PersonAddress
Where not City = 'Seattle'

Select * From PersonAddress
Where City != 'Seattle'

Select * From PersonAddress
Where Apartment is not null

Select * From PersonAddress
Where Apartment is  null

Select * From Donation
Where DonationDate > '3/1/2010'

Select * From Donation
Where DonationAmount Between 1000 and 2000

Select * From Donation
Where DonationAmount >= 1000 and donationAmount <= 2000

Select * From Donation
Where DonationDate Between '3/1/2010' and '3/31/2010'

Select * From PersonAddress
Where Street like '%Way%'

Select * From Person
Where LastName like 'S%'

No comments:

Post a Comment