Tuesday, January 8, 2019

Selects

--Selects
Select * From Person; -- this takes more processing time since it will need to figure out what all the columns are
Select personlastname, personfirstname, personemail -- this will run faster since columns are specified
From Person;
Select personfirstname As "First Name", --you can use "as" to label your output table columns
personlastname As "Last Name", 
personemail As "Email" From Person;

Select personkey, personfirstname, personlastname, personemail
From Person
order by personlastname, personfirstname Desc;

select * From donation where personkey = 6;

Select * From personaddress
Where personaddresscity = 'Bellevue'; -- not typically case sensitive but ours is

Select * From personaddress
Where NOT personaddresscity = 'Seattle';

Select personkey, personaddressstreet, personaddressapt
From personaddress
Where personaddressapt is null OR personaddressapt = ' ';

Select personaddressstreet, personaddressapt
From Personaddress
Where personaddressapt is null or personaddressapt='';

--11
Select personaddressstreet, personaddressapt
From Personaddress
Where personaddressapt is not null; 

Select personaddressstreet, personaddressapt
From Personaddress
Where personaddressapt = null; 

Select * from Donation;

Select * from donation where donationamount >1000
order by donationamount desc;

Select * from donation where donationamount between 1000 and 1500
order by donationamount desc;

Select * from donation where donationdate between '2017-06-01' And '2017-07-31';

Select * from donation where donationamount <= 1000;

Insert into donation (personkey, donationamount, donationdate)
Values (6, 500, current_timestamp);

Select * from donation where donationdate = '2019-01-08';

Select Personfirstname, personlastname 
from person
where personlastname like 'L%n';

Select Personfirstname, personlastname 
from person
where personlastname like 'Car_l';

--Distinct
Select distinct personkey from donation
order by personkey;

No comments:

Post a Comment