Wednesday, January 8, 2014

Simple Selects

Use Automart
/*this is a multiline
comment. this example is 
for assignment 1*/

Select * From Person;

--Simple select listing columns
Select FirstName, LastName 
From Person

Select Lastname, firstName
from Person
order by Lastname 

Select Lastname, Firstname
From person
order by lastname desc, firstname

Select lastname as [Last Name], firstName as [first Name]
From Person

--preview
Select ServiceName, servicePrice, 
cast(Round(ServicePrice * .09, 2)as decimal(5,2)) Tax
From Customer.Autoservice

Select Servicename, servicePrice
From Customer.Autoservice
Where serviceName='tune up'

Select * From Employee.VehicleService
Where ServiceDate='2/25/2010'

Select ServiceName, ServicePrice
From customer.AutoService
Where  ServicePRice   > 100

--<, >, =, !=, >=, <=

Select Distinct VehicleID from Employee.VehicleService
order by VehicleID

Select * from  Employee
Where supervisorID is not null

Select * from  Employee
Where supervisorID is not null
And SupervisorID=6


Select * from  Employee
Where supervisorID is  null
or SupervisorID=6

Select * from Employee.VehicleService
Where ServiceDate between '2/1/2010' and '2/28/2010'

Select GetDate()

Select * from Person
order by lastname

Select * from Person
where lastname like 'C%l'

--% any number of characters
-- _ for one character

No comments:

Post a Comment