Viewing 15 posts - 1 through 15 (of 17 total)
That's great many thanks. Gosh wish I had similar level. Much appreciated for the thorough explanations.
June 27, 2022 at 1:59 pm
Just one more question. If I want for only to appear the fieldsย 'MaxMinDesc' and the 'VacationHours' how would I do it? I have tried taking the asterixes off as...
June 27, 2022 at 8:15 am
Ok that's great many thanks for giving such a good explanation step-by-step. So very helpful ๐
June 27, 2022 at 8:09 am
Thank Ed. It works brilliant too and I was trying to work it out with case/where statements to tell you the truth but no success from me of course.
However, can...
June 25, 2022 at 8:30 am
Perfect ๐
So thankful it works perfect. Now have to try to go through it and actually understand it. That was brilliant.
June 23, 2022 at 3:40 pm
Thank Phil. It gives me the below errors;
Msg 209, Level 16, State 1, Line 35
Ambiguous column name 'vacationhours'.
Msg 8156, Level 16, State 1, Line 30
The column 'VacationHours' was specified multiple...
June 23, 2022 at 3:33 pm
The first 2 fields would be as below (first row below are the headings);
Vacation_Hours ---Hours
Max_Hours---------99
Min_Hours----------0
June 23, 2022 at 2:34 pm
Apologies for my poor explanation. I just mixed terms like variables (var) which is misleading.
It works Phil but it doesn't give the name on each records. I would need two...
June 23, 2022 at 2:25 pm
Sorry but to note that in your query, each variable (max and min) has a record name but only brings the first one ("'Max_VacationHours'") as a header. The second you...
June 23, 2022 at 1:58 pm
Hi Phil Parkin. I've just realised that, even that your query below works in a sense, it doesn't give me 2 separated variables with the names of 'min hours' and...
June 23, 2022 at 1:54 pm
Ok, this actually works I must have run the wrong query ๐
But, why "mx" and "mn" and what does the WITH function dos in this case?
I suppose it's max and...
June 21, 2022 at 2:11 pm
Phil, I've tried the below and brings error "Incorrect syntax near 'des'.";
WITH mx
AS (SELECT TOP (1)
Dsc = 'Max Vacation Hours'
,*
FROM HumanResources.Employee
ORDER BY vacationhours DESC)
,mn
AS (SELECT TOP (1)
Dsc = 'Min Vacation...
June 21, 2022 at 2:07 pm
Phil Parkin, on saying that I've just realised that it doesn't give correct results.
Select TOP (1) 'Max Vacation Hours' as 'Vacation Hours', *
From [HumanResources].[Employee]
UNION ALL ---- UNION on its own...
June 21, 2022 at 2:05 pm
Ok, point taken about the UNION ALL. Many thanks
Always good to learn alternative ways to learn if anybody can provide a solution to it to avoid giving the same result...
June 21, 2022 at 11:48 am
Ok, I think that I got it sorted.
All I've done is to omit ORDER BY function in the first query as below;
Select TOP (1) 'Max Vacation Hours', *
From [HumanResources].[Employee]
Union
Select TOP...
June 21, 2022 at 11:39 am
Viewing 15 posts - 1 through 15 (of 17 total)