February 4, 2019 at 12:55 pm
Greetings,
I am currently aiming to create a query for educational purposes in SQL 2017 Express as follows:
Search within Employee Salaries:
Any Salaries that start with: 10, 12, 15
The Salaries contain decimal values, so the query will display any salary as follows:
10.xx
12.xx
15.xx
where xx is a decimal value within the salary being search.
I've tried several methods and so far, I have been able to execute(with no errors) the following queries. The first two show no output but successful execution, the last one displays outputs but no Hourly Rates beyond xx.00
First Attempt:
SELECT FirstName, LastName, HourlyRate FROM Employee
WHERE HourlyRate IN (10., 12., 15.) AND HourlyRate LIKE '%.__';
Second Attempt:
SELECT FirstName, LastName, HourlyRate FROM Employee
WHERE HourlyRate IN (10., 12., 15.) AND ((HourlyRate *10)%1) >0;
Third Attempt:
SELECT FirstName, LastName, HourlyRate FROM Employee
WHERE HourlyRate IN (10., 12., 15.) AND HourlyRate LIKE '%.%'
The third attempt displays and output of whole number (10.00, 12.00, 15.00) but doesn't display any other salaries with additional decimal values.
I thank you in advance for any guidance or support you could provide
Sincerely Yours,
February 4, 2019 at 1:08 pm
p.hernandez75 - Monday, February 4, 2019 12:55 PMGreetings,
I am currently aiming to create a query for educational purposes in SQL 2017 Express as follows:Search within Employee Salaries:
Any Salaries that start with: 10, 12, 15
The Salaries contain decimal values, so the query will display any salary as follows:
10.xx
12.xx
15.xx
where xx is a decimal value within the salary being search.
I've tried several methods and so far, I have been able to execute(with no errors) the following queries. The first two show no output but successful execution, the last one displays outputs but no Hourly Rates beyond xx.00
First Attempt:
SELECT FirstName, LastName, HourlyRate FROM Employee
WHERE HourlyRate IN (10., 12., 15.) AND HourlyRate LIKE '%.__';
Second Attempt:
SELECT FirstName, LastName, HourlyRate FROM Employee
WHERE HourlyRate IN (10., 12., 15.) AND ((HourlyRate *10)%1) >0;Third Attempt:
SELECT FirstName, LastName, HourlyRate FROM Employee
WHERE HourlyRate IN (10., 12., 15.) AND HourlyRate LIKE '%.%'The third attempt displays and output of whole number (10.00, 12.00, 15.00) but doesn't display any other salaries with additional decimal values.
I thank you in advance for any guidance or support you could provide
Sincerely Yours,
Do you know how to use EXISTS? It's a great option for this kind of queries when you need to make advanced comparisons on multiple values.
SELECT FirstName, LastName, HourlyRate
FROM Employee e
WHERE EXISTS(SELECT *
FROM (VALUES(10., 12., 15.))x (rate)
WHERE HourlyRate > = x.rate
AND HourlyRate < x.rate);
February 4, 2019 at 1:50 pm
Greetings,
I am new to SQL and not familiar with the EXISTS Clause. I will research the clause and will execute as explained.
Thank you very much for your prompt reply and guidance.
Yours Truly,
February 5, 2019 at 9:15 am
p.hernandez75 - Monday, February 4, 2019 1:50 PMGreetings,
I am new to SQL and not familiar with the EXISTS Clause. I will research the clause and will execute as explained.
Thank you very much for your prompt reply and guidance.
Yours Truly,
I hope that you were able to understand the usage of EXISTS. If you have any questions, feel free to ask them.
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply