Read our blogs, tips and tutorials
Try our exercises or test your skills
Watch our tutorial videos or shorts
Take a self-paced course
Read our recent newsletters
License our courseware
Book expert consultancy
Buy our publications
Get help in using our site
551 attributed reviews in the last 3 years
Refreshingly small course sizes
Outstandingly good courseware
Whizzy online classrooms
Wise Owl trainers only (no freelancers)
Almost no cancellations
We have genuine integrity
We invoice after training
Review 30+ years of Wise Owl
View our top 100 clients
Search our website
We also send out useful tips in a monthly email newsletter ...
select
left(tc.categoryname,1) as [Category intial],
count(te.eventid) as [No of Events],
cast(avg(cast(len(te.eventname) as float)) as decimal(6,2)) as [Average event name length]
from tblevent as te
inner join tblCategory tc on te.CategoryID=tc.CategoryID
group by left(tc.categoryname,1)
select count(eventid) as [No of Event],
Max(eventdate) as [Last date],
Min(eventdate) as [First date]
from tblevent
select EventName, concat(week_name,' ',date_name,' ',month_name,' ',year_no) as 'Full date' from
(select eventname,eventdate,datename(weekday,eventdate) as week_name,datename(year,eventdate) as year_no,datename(month,eventdate)as month_name
,datename(day,eventdate)as date_no,
case
when datename(day,eventdate) = 1 then '1st'
when datename(day,eventdate) =2 then '2nd'
when datename(day,eventdate) = 3 then '3rd'
when datename(day,eventdate) not in (1,2,3) then CONCAT(cast(datename(day,eventdate) as varchar(10)),'th')
end as date_name
from tblevent
) as t
order by eventdate
select EventName,EventDate, datename(weekday,eventdate) as 'Day of week',datename(day,eventdate) as 'Day number'
from tblEvent
where datename(weekday,eventdate) = 'Friday'
and
datename(day,eventdate) = '13'
select Eventname, eventdate as NotFormated,
format(eventdate,'dd/MM/yyyy') as UsingFormat,
convert(varchar,EventDate, 103)
from tblEvent
where year(eventdate) = '1995'
select Eventname, eventdate as NotFormated,
format(eventdate,'dd/MM/yyyy') as UsingFormat,
convert(varchar,EventDate, 103)
from tblEvent
select Countryname,
case
when continentid in (1,3) then 'Eurasia'
when continentid in (5,6) then 'Americas'
when continentid in (2,4) then 'somewhere hot'
when continentid in (7) then 'somewhere cold'
else 'somewhere else'
end as 'Countrylocation'
from tblCountry
order by countryLocation desc
select *,isnull(summary,'No summary') as 'Using isnull',coalesce(summary,'No summary') as 'Using Coalensce',
case
when summary is null then 'No Summary' else Summary
end 'Using case'
from tblContinent
select concat(eventname,' (category ',cast(CategoryID as varchar),')') as 'Event (category)',Eventdate from tblEvent
where countryid = 1
select *,concat(eventname,' (category ',cast(CategoryID as varchar),')') as mer from tblEvent
where countryid = 1
first I created view for simplicty then use logic,
/*Create view table1
as
select EventName,lower(left(eventname,1)) as lefty,lower(right(eventname,1)) as righty from tblEvent*/
select * from
(select eventname,
Case
when lefty=righty
then 'Same letter'
when righty in ('a','e','i','o','u') and lefty in ('a','e','i','o','u')
then 'Begin and ends with vowel'
end as 'verdict'
from table1) as t
where verdict is not null
select EventName,LEN(EventName) as length_name from tblEvent
select * from tblEvent
where eventname like '%Teletubbies%' or eventname like '%Pandy%'
select * from tblEvent
where categoryid in (5,6) and EventDetails not like '%War%' and EventDetails not like '%Death%'
Kingsmoor House
Railway Street
GLOSSOP
SK13 2AA
Landmark Offices
99 Bishopsgate
LONDON
EC2M 3XD
Holiday Inn
25 Aytoun Street
MANCHESTER
M1 3AE
© Wise Owl Business Solutions Ltd 2024. All Rights Reserved.