SQL - Will this work? - HotUKDeals
We use cookie files to improve site functionality and personalisation. By continuing to use HUKD, you accept our cookie and privacy policy.
Get the HUKD app free at Google Play

Search Error

An error occurred when searching, please try again!

Login / Sign UpSubmit

SQL - Will this work?

SAVE4IT Avatar
6y, 9m agoPosted 6 years, 9 months ago
Hi there,

I am having problems with the MYSQL Command Line client on my computer and was wondering if you think these queries will work. Assuming that correct tables and data have been inputted.

This should select the average length of time someone stays at a hotel at any one time:

SELECT [Hotel Name], AVG(DATEDIFF ( "y" , FORMAT ( [Date of Arrival], "DD/MM/YYYY") , FORMAT ( [Date of departure], "DD/MM/YYYY") )) AS [Average Days]
FROM Booking_details
GROUP BY [Hotel Name]

Thanks. I'm unsure if the Square brackets are required?
SAVE4IT Avatar
6y, 9m agoPosted 6 years, 9 months ago
Options

All Comments

(6) Jump to unreadPost a comment
Comments/page:
banned#1
dude there is a MySQL forum. use that. or read your SQL books and that way you'll learn
#2
bykergrove
dude there is a MySQL forum. use that. or read your SQL books and that way you'll learn


may i recommend SQL for dummies.....
#4
ALT + F4 works for me
#5
SELECT Hotel Name, AVG(DATEDIFF ( "y" , FORMAT ( Date of Arrival, "DD/MM/YYYY") , FORMAT ( Date of departure, "DD/MM/YYYY") AS Average Days
FROM Booking_details
GROUP BY Hotel Name

Try that, you had too many end brackets and delete the square ones.

As all the others has said, you're probably better off asking on a sql forum as you'll get more advice.
#6

Post a Comment

You don't need an account to leave a comment. Just enter your email address. We'll keep it private.

...OR log in with your social account

...OR comment using your social account

Thanks for your comment! Keep it up!
We just need to have a quick look and it will be live soon.
The community is happy to hear your opinion! Keep contributing!