SQL Queries for Employee Data Analysis
SQL Queries for Employee Data Analysis
The SQL query would be structured as: SELECT NAME FROM STUDENT WHERE (GRADE1 = 'C' OR GRADE2 = 'C') AND NAME LIKE 'A%'; This filters students based on their grades and initial letter of their names at the same time .
To list only the distinct games offered at the school, use: SELECT DISTINCT GAME FROM STUDENT; This query will return a list of games without duplicates, ensuring each game is mentioned only once .
The query for listing all orders without nulls or zeros is: SELECT * FROM ORDER WHERE AMT <> 0 AND AMT IS NOT NULL; It ensures all retrieved orders have a defined, non-zero amount .
The query would be: SELECT * FROM CUSTOMERS WHERE RATING > 100 OR CITY = 'SHIMLA'; This logic includes all Shimla residents despite their ratings and excludes others rated below 100 .
The query would be: SELECT ENAME FROM EMPL WHERE ENAME LIKE 'M_L%'; This pattern-based query searches for names with these specific character positions defined .
To retrieve customers with a rating greater than 100 and exclude those in Shimla, you can write: SELECT * FROM CUSTOMERS WHERE RATING > 100 AND CITY <> 'SHIMLA'; This query specifically selects customers who exceed the rating threshold unless they are located in Shimla .
To display employee names and salaries for those whose salaries are neither between 2500 and 4000 nor above 4000, you can combine conditions with the NOT BETWEEN operator as follows: SELECT ENAME, SAL FROM EMPL WHERE SAL < 2500 OR SAL > 4000. This ensures we only select employees whose salaries fall outside the specified range .
To retrieve students whose SUPW names start with 'A', use: SELECT SUPW, NAME FROM STUDENT WHERE NAME LIKE 'A%'; This query effectively utilizes SQL wildcard to filter results based on the starting character of the students' names .
The SQL query to select employees who do not receive commissions and have salaries over 2200 is: SELECT ENAME, SAL FROM EMPL WHERE COMM IS NULL AND SAL > 2200; This ensures the retrieved employees meet both criteria .
To find employees with no manager and a name ending in 'T', you can use a combination of conditions: SELECT ENAME FROM EMPL WHERE MGR IS NULL AND ENAME LIKE '%T'; This ensures the query checks for both conditions simultaneously .