Nandini Ikhankar’s Post

View profile for Nandini Ikhankar, graphic

Data Analyst | Advanced Excel | Power BI | MY SQL | Data Visualization

God morning connectio🌻 Here are five advanced MySQL functions and their explanations: 1. What is the COALESCE() function in MySQL? :- The COALESCE() function returns the first non-null value in a list of arguments. It's useful for handling null values in queries. For example, `SELECT COALESCE(column1, column2, 'Default Value') FROM table;` will return the first non-null value from column1 and column2, or 'Default Value' if both are null. 2. How does the CASE statement work in MySQL? :- The CASE statement allows you to perform conditional logic in your queries. It can return different values based on specific conditions. For instance: ```sql SELECT name, CASE WHEN salary < 30000 THEN 'Low' WHEN salary BETWEEN 30000 AND 60000 THEN 'Medium' ELSE 'High' END AS salary_category FROM employees; ``` This query categorizes salaries into 'Low', 'Medium', or 'High'. 3. What is the purpose of the GROUP_CONCAT() function? :- The GROUP_CONCAT() function concatenates values from multiple rows into a single string. It's particularly useful for creating comma-separated lists. For example: ```sql SELECT department, GROUP_CONCAT(employee_name) AS employees FROM employees GROUP BY department; ``` This will give you a list of employee names for each department. 4. Explain the use of the RANK() function in MySQL. :- The RANK() function assigns a unique rank to each row within a partition of a result set, based on the specified column values. Rows with the same values receive the same rank, and the next rank is skipped. For example: ```sql SELECT name, salary, RANK() OVER (ORDER BY salary DESC) AS rank FROM employees; ``` This will rank employees based on their salaries in descending order. 5. What is the purpose of the JSON functions in MySQL? :- MySQL provides various JSON functions to handle JSON data types. Functions like JSON_EXTRACT(), JSON_ARRAY(), and JSON_OBJECT() allow you to manipulate and query JSON data stored in tables. For example: ```sql SELECT JSON_EXTRACT(data, '$.name') AS name FROM users; ``` This will extract the 'name' field from a JSON column named 'data'. #data #analytics #mysql #server #hr #motivated

Shubham Dey

Advanced Excel | Power BI | MY SQL | Data Visualization | Certified DATA ANALYST

2mo

Very helpful

Like
Reply

To view or add a comment, sign in

Explore topics