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
546 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 ...
Software ==> | SQL (203 exercises) |
Topic ==> | Calculations using dates (7 exercises) |
Level ==> | Average difficulty |
Subject ==> | SQL training |
This exercise is provided to allow potential course delegates to choose the correct Wise Owl Microsoft training course, and may not be reproduced in whole or in part in any format without the prior written consent of Wise Owl.
This will generate the database that you'll need to use in order to do this exercise (note that the database and script are only to be used for exercises published on this website, and may not be reused or distributed in any form without the prior written permission of Wise Owl).
The idea behind this exercise is to see what was happening in the world around the time when you were born (but you can use any reference date). First create a query to show the number of days which have elapsed for any event since your birthday:
For an imaginary trainer born on 4th March 1964, this is what they'd see (your list will be different).
The ABS function returns the absolute value of a number (for example, ABS(42) and ABS(-42) both equal 42). Use this to list the events in order of closeness to your birthday:
For the same completely imaginary trainer, these are the events that they would see.
You need to take the absolute value because the closest event to your birthday may be just before it (in which case the offset days will be negative) or just after it (in which case the offset days will be positive).
Was yours an auspicious year? Save this query as Birth pool, then close it down.
You can find other training resources for the subject of this exercise here:
From: | Chinmaykumar |
When: | 04 Jul 23 at 11:41 |
Query_Sol. for MySQL users
-- number of offset days since your birthday
-- In date format, "%b" is used to show "Abbreviated month name (Jan to Dec)"
SELECT EventName, DATE_FORMAT(EventDate,'%d %b %Y') Event_Date,
DATEDIFF(EventDate,'1964-03-04') 'Days offset'
FROM tblevent
ORDER BY DATEDIFF(EventDate,'1964-03-04') DESC;
-- this exercise is to see what was happening in the world around the time when you were born
SELECT EventName, DATE_FORMAT(EventDate,'%d %b %Y') Event_Date,
DATEDIFF('1964-03-04', EventDate) 'Days offset',
ABS(DATEDIFF('1964-03-04', EventDate)) 'Days difference'
FROM tblevent
ORDER BY ABS(DATEDIFF('1964-03-04', EventDate)) ASC;
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.