--scalar functions Use CommunityAssist Select DonationKey, [DonationAmount],[DonationDate] From Donation Select DonationKey, DonationAmount, DonationAmount * .8 as Charity, DonationAmount * .2 as [Admin] From Donation Select 10 * 2 % (4 + 12) Select DonationDate, DonationAmount From Donation Select Month(DonationDate) as [Month], donationamount From Donation Where Month(DonationDate)=3 Select Day(donationDate) from Donation Select Distinct Year(DonationDate) From Donation Select Distinct DatePart(YY, DonationDate) as [Year] From Donation Select Cast(DatePart(mm, DonationDate)as Nvarchar) + '/' + cast(Datepart(dd,DonationDate) as Nvarchar) + '/' + cast(DatePart(YY, DonationDate)as nvarchar) as [Date] From Donation Select Datepart(hour, GetDate()), Datepart(Minute, GetDate()) Select Datepart(Minute, GetDate()) Select DateAdd(dd, 30, GetDate()) Select DateDiff(mm, GetDate(), '3/22/2013'); Select ContactInfo, substring(ContactInfo, 1, 3) as [Area Code], Substring (ContactInfo, 4, 3) as Exhange, Substring (ContactInfo, 7, 4) as number From PersonContact Where ContactTypeKey < 6 --find a space --charindex locates a particular character in this case -- as space, so the following reads --select a substring of the field street, starting with character 1 --return the number of characters up to the first space Select Charindex(' ', Street) as [Location of first Space], Substring(Street,1, Charindex(' ', Street)) as [first] From PersonAddress
Wednesday, January 9, 2013
Scalar Functions Assignment 2
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment