## Posts

Showing posts with the label Dictionary

### 5 SQL Queries That Popularly Used in Data Analysis

Here are five popular SQL queries frequently used in data analysis. 1. SELECT with Aggregations Summarize data by calculating aggregates like counts, sums, averages, etc. SELECT department, COUNT(*) as employee_count, AVG(salary) as average_salary FROM employees GROUP BY department; 2. JOIN Operations  Combine data from multiple tables based on a related column. SELECT e.employee_id, e.name, d.department_name FROM employees e JOIN departments d ON e.department_id = d.department_id; 3. WHERE Clause for Filtering Filter records based on specified conditions. SELECT * FROM sales WHERE sale_date BETWEEN '2024-01-01' AND '2024-12-31'   AND amount > 1000; 4. ORDER BY Clause for Sorting Sort results in ascending or descending order based on one or more columns. SELECT product_name, price FROM products ORDER BY price DESC; 5. GROUP BY with HAVING Clause Group records and apply conditions to the aggregated results. SELECT department, SUM(salary) as total_salaries FROM employ

# How to Access Dictionary Key-Value Data in Python

Use for-loop to read dictionary data in python. Here's an example of reading dictionary data. It's helpful to use in real projects. Python program to read dictionary data yearly_revenue = {    2017 : 1000000,    2018 : 1200000,    2019 : 1250000,    2020 : 1100000,    2021 : 1300000,  } total_income = 0 for year_id in yearly_revenue.keys() :   total_income+=yearly_revenue[year_id]   print(year_id, yearly_revenue[year_id]) print(total_income) print(total_income/len(yearly_revenue)) Output 2017 1000000 2018 1200000 2019 1250000 2020 1100000 2021 1300000 5850000 1170000.0 ** Process exited - Return Code: 0 ** Press Enter to exit the terminal Explanation The input is dictionary data. The total revenue sums up for each year. Notably, the critical point is using the dictionary keys method. References Python in-depth and sample programs