Table: Employees +-------------+---------+ | Column Name | Type | +-------------+---------+ | employee_id | int | | name | varchar | | salary | int | +-------------+---------+ If Employee name does not start with M, AND salary is an odd number, give them a bonus of 100%. -- select entries with odd employee id and name not start with M select employee_id , salary as bonus from employees where employee_id%2 <>0 and name not like 'M%' -- join both selection union -- select remaining entries from table select employee_id , 0 as bonus from employees where employee_id%2 = 0 or name like 'M%' order by employee_id;
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter