You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
Query the Name of any student in STUDENTS who scored higher than Marks. Order your output by the last three characters of each name. If two or more students both have names ending in the same last three characters (i.e.: Bobby, Robby, etc.), secondary sort them by ascending ID.
311
+
Query the Name of any student in STUDENTS who scored higher than75 Marks. Order your output by the last three characters of each name. If two or more students both have names ending in the same last three characters (i.e.: Bobby, Robby, etc.), secondary sort them by ascending ID.
287
312
```sql
288
313
-- mysql
289
-
314
+
SELECT Name
315
+
FROM STUDENTS
316
+
WHERE Marks>75
317
+
ORDER BY RIGHT(Name,3), IDASC;
290
318
```
291
319
292
-
###
293
320
321
+
##EMPLOYEE table used for all below
322
+

323
+
324
+
###Employee Names
325
+
Write a query that prints a list of employee names (i.e.: the name attribute) from the Employee table in alphabetical order.
294
326
```sql
295
327
-- mysql
296
-
328
+
SELECT name
329
+
FROM EMPLOYEE
330
+
ORDER BY name;
297
331
```
298
332
299
-
###
333
+
###Employee Salaries
334
+
Write a query that prints a list of employee names (i.e.: the name attribute) for employees in Employee having a salary greater than $2000 per month who have been employees for less than 10 months. Sort your result by ascending employee_id.
335
+
```sql
336
+
-- mysql
337
+
SELECT name
338
+
FROM EMPLOYEE
339
+
WHERE salary>2000AND months<10
340
+
ORDER BY employee_idASC;
341
+
```
300
342
343
+
###Top Earners
344
+
We define an employee's total earnings to be their monthly`salary x months` worked, and the maximum total earnings to be the maximum total earnings for any employee in the Employee table. Write a query to find the maximum total earnings for all employees as well as the total number of employees who have maximum total earnings. Then print these values as`2` space-separated integers.
301
345
```sql
302
346
-- mysql
347
+
SELECT
348
+
MAX(salary* months)AS max_total_earnings,
349
+
COUNT(*)AS num_employees
350
+
FROM EMPLOYEE
351
+
WHERE salary* months= (
352
+
SELECTMAX(salary* months)FROM EMPLOYEE
353
+
);
354
+
```
355
+
356
+
357
+
358
+
##EMPLOYEES table used for all below
359
+

303
360
361
+
###The Blunder
362
+
Samantha was tasked with calculating the average monthly salaries for all employees in the EMPLOYEES table, but did not realize her keyboard's 0 key was broken until after completing the calculation. She wants your help finding the difference between her miscalculation (using salaries with any zeros removed), and the actual average salary.
363
+
Write a query calculating the amount of error (i.e.:`actual - miscalculated` average monthly salaries), and round it up to the next integer.