<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Nyamatari Brian</title>
    <description>The latest articles on DEV Community by Nyamatari Brian (@nyamatari_brian_c41e0c389).</description>
    <link>https://dev.to/nyamatari_brian_c41e0c389</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3818267%2F879f09e2-7167-4209-adf7-4e2832973596.png</url>
      <title>DEV Community: Nyamatari Brian</title>
      <link>https://dev.to/nyamatari_brian_c41e0c389</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/nyamatari_brian_c41e0c389"/>
    <language>en</language>
    <item>
      <title># Advanced SQL Concepts Using a Hospital Management Dataset.</title>
      <dc:creator>Nyamatari Brian</dc:creator>
      <pubDate>Mon, 23 Nov 2026 05:36:48 +0000</pubDate>
      <link>https://dev.to/nyamatari_brian_c41e0c389/-advanced-sql-concepts-using-a-hospital-management-dataset-3o0f</link>
      <guid>https://dev.to/nyamatari_brian_c41e0c389/-advanced-sql-concepts-using-a-hospital-management-dataset-3o0f</guid>
      <description>&lt;h2&gt;
  
  
  Introduction.
&lt;/h2&gt;

&lt;p&gt;Structured Query Language (SQL) is one of the most important tools used by data analysts, data scientists and data engineers to extract, structure, manipulate and analyse data within relational databases. Within a hospital management system, SQL can be used to look at patient data, track admissions, calculate costs of treatments, look at doctor performance and produce reports.&lt;/p&gt;

&lt;p&gt;In addition to basic commands like SELECT, INSERT, UPDATE and DELETE, there are many additional tools available to help you perform more complex data analysis. Four very important concepts to understand are window functions, SQL joins, Common Table Expressions (CTEs) and subqueries.&lt;/p&gt;

&lt;p&gt;This article will explain what they are, how they work, when to use them and how they can be used to solve real world problems in a hospital setting. Examples using SQL will be given for each concept, including an explanation of the query and what you would expect to see.&lt;/p&gt;

&lt;p&gt;Assumptions about the data: As the exact data from the hospital and attached class notes isn't visible within this message, examples have been created using a sample hospital database. This will include tables such as patients, doctors, departments, admissions and payments. The queries use general SQL syntax which should be widely supported, but some features may depend on the database you're using. You can change the table and column names to match those in your class dataset.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. SQL Window Functions.
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1.1 What are SQL window Functions?
&lt;/h3&gt;

&lt;p&gt;The window function allows you to perform calculations on sets of related rows. These functions work slightly differently to standard aggregate functions. Window functions calculate values for each row of data based on the specified set/ window of data.&lt;/p&gt;

&lt;p&gt;A hospital administrator may want to know:&lt;/p&gt;

&lt;p&gt;What is the ranking of doctors based on how many patients they see?&lt;/p&gt;

&lt;h3&gt;
  
  
  1.2 Understanding the Over () clause.
&lt;/h3&gt;

&lt;p&gt;The OVER() clause tells SQL which rows a window function should consider when performing its calculation.&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
SELECT&lt;br&gt;
    admission_id,&lt;br&gt;
    patient_id,&lt;br&gt;
    admission_cost,&lt;br&gt;
    AVG(admission_cost) OVER () AS hospital_average_cost&lt;br&gt;
FROM admissions;&lt;/p&gt;

&lt;p&gt;Explanation:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;AVG(admission_cost) calculates the average admission cost.&lt;/li&gt;
&lt;li&gt;OVER() defines the window over which the calculation takes place.&lt;/li&gt;
&lt;li&gt;Because no partition or ordering is specified, the average is calculated across all rows included in the query.&lt;/li&gt;
&lt;li&gt;Each admission remains in the result, and each row displays the same hospital-wide average.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  1.3 The Partition By clause.
&lt;/h3&gt;

&lt;p&gt;PARTITION BY divides the result set into separate groups. A window function then performs its calculation independently within each group.&lt;/p&gt;

&lt;p&gt;Example: Calculate the average admission cost for each department.&lt;/p&gt;

&lt;p&gt;SELECT&lt;br&gt;
    admission_id,&lt;br&gt;
    department_id,&lt;br&gt;
    admission_cost,&lt;br&gt;
    AVG(admission_cost) OVER (&lt;br&gt;
        PARTITION BY department_id&lt;br&gt;
    ) AS department_average_cost&lt;br&gt;
FROM admissions;&lt;/p&gt;

&lt;p&gt;Explanation: The admissions will be grouped by department_id and each admission will have a column showing the average cost of admissions for their department, but we won't aggregate into one row.&lt;/p&gt;

&lt;p&gt;For example: If the average cost of admissions in the Cardiology department is KSh 20,000, each admission in Cardiology will have a column with the value KSh 20,000.&lt;/p&gt;

&lt;h3&gt;
  
  
  1.4 The Order By clause.
&lt;/h3&gt;

&lt;p&gt;Within OVER(), ORDER BY determines the order in which rows are ranked or processed by the window function.&lt;/p&gt;

&lt;p&gt;Example: Rank admissions by cost, from highest to lowest.&lt;/p&gt;

&lt;p&gt;SELECT&lt;br&gt;
    admission_id,&lt;br&gt;
    admission_cost,&lt;br&gt;
    ROW_NUMBER() OVER (&lt;br&gt;
        ORDER BY admission_cost DESC&lt;br&gt;
    ) AS cost_position&lt;br&gt;
FROM admissions;&lt;/p&gt;

&lt;p&gt;Explanation: The highest priced admission gets value 1, then next highest gets value 2 etc. Even if two admission prices are the same, the ROW_NUMBER() function will still assign unique values. This may lead to an arbitrary ordering of the results unless we have a tiebreaker.&lt;/p&gt;

&lt;h3&gt;
  
  
  1.5 Window Frames.
&lt;/h3&gt;

&lt;p&gt;The window frame determines which of the rows in the window are included in the calculation for the current row. This is useful when performing running totals, moving averages or rolling calculations.&lt;br&gt;
Common window frames are:&lt;/p&gt;

&lt;p&gt;ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW will start from the first row in the window up to and including the current row.&lt;br&gt;
ROWS BETWEEN 2 PRECEDING AND CURRENT ROW will take the current row and the previous 2 rows.&lt;br&gt;
ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING Will take from the current row up to and including the last row in the window.&lt;/p&gt;

&lt;p&gt;Example: Calculate a running total of hospital admissions revenue.&lt;/p&gt;

&lt;p&gt;SELECT&lt;br&gt;
    admission_id,&lt;br&gt;
    admission_date,&lt;br&gt;
    admission_cost,&lt;br&gt;
    SUM(admission_cost) OVER (&lt;br&gt;
        ORDER BY admission_date, admission_id&lt;br&gt;
        ROWS BETWEEN UNBOUNDED PRECEDING&lt;br&gt;
                 AND CURRENT ROW&lt;br&gt;
    ) AS running_revenue&lt;br&gt;
FROM admissions;&lt;/p&gt;

&lt;p&gt;Explanation: The SQL will sort the admissions based on the admission date and admission ID. It will then add up the admission fee and give us a running total. The first row will show the cost, the second will show the running total up to that point etc.&lt;/p&gt;

&lt;p&gt;If the admission costs are 5000KSh, 8000KSh and 2000KSh respectively, the SQL will return:&lt;/p&gt;

&lt;p&gt;5000KSh, 13000KSh, 15000KSh.&lt;/p&gt;

&lt;p&gt;The difference between having an ORDER BY clause inside the OVER() function and having it at the end of your SQL is that it will decide the order in which the calculations happen. Whereas having an ORDER BY clause at the end of your SQL will decide how the data will appear.&lt;/p&gt;

&lt;h3&gt;
  
  
  1.6 Types of SQL window Functions.
&lt;/h3&gt;

&lt;p&gt;Window functions can be divided into ranking functions, navigation functions, value functions, and aggregate window functions&lt;/p&gt;

&lt;h4&gt;
  
  
  Row_Numbers().
&lt;/h4&gt;

&lt;p&gt;What it does&lt;/p&gt;

&lt;p&gt;Gives a unique sequential number to each row in a window starting at 1.&lt;/p&gt;

&lt;p&gt;Why it is used&lt;/p&gt;

&lt;p&gt;Can be used to see the earliest admission, pick the most recent entry per patient or to eliminate duplicated entries by ranking.&lt;/p&gt;

&lt;p&gt;Example in hospital&lt;/p&gt;

&lt;p&gt;To give a sequential count of admissions per patient.&lt;/p&gt;

&lt;p&gt;SELECT&lt;br&gt;
    patient_id,&lt;br&gt;
    admission_id,&lt;br&gt;
    admission_date,&lt;br&gt;
    ROW_NUMBER() OVER (&lt;br&gt;
        PARTITION BY patient_id&lt;br&gt;
        ORDER BY admission_date DESC, admission_id DESC&lt;br&gt;
    ) AS admission_number&lt;br&gt;
FROM admissions;&lt;/p&gt;

&lt;h4&gt;
  
  
  Rank().
&lt;/h4&gt;

&lt;p&gt;What it does&lt;/p&gt;

&lt;p&gt;Sorts your data into a specific order and assigns each row a number. If two rows have the same value they will be given the same rank, however there will be gaps between the next ranks.&lt;/p&gt;

&lt;p&gt;Why you would use it&lt;/p&gt;

&lt;p&gt;It can be useful to find out which of your doctors are performing the best or which department makes the most revenue, whilst allowing for the same ranks.&lt;/p&gt;

&lt;p&gt;SELECT&lt;br&gt;
    doctor_id,&lt;br&gt;
    SUM(admission_cost) AS total_revenue,&lt;br&gt;
    RANK() OVER (&lt;br&gt;
        ORDER BY SUM(admission_cost) DESC&lt;br&gt;
    ) AS revenue_rank&lt;br&gt;
FROM admissions&lt;br&gt;
GROUP BY doctor_id;&lt;/p&gt;

&lt;h4&gt;
  
  
  Dense_Rank().
&lt;/h4&gt;

&lt;p&gt;Purpose: This function ranks your data (like RANK()) without leaving gaps between duplicate values.&lt;/p&gt;

&lt;p&gt;Why it's useful: Useful if you want to rank departments or doctors in a hospital that have the same level of performance, consecutively.&lt;/p&gt;

&lt;p&gt;SELECT&lt;br&gt;
    doctor_id,&lt;br&gt;
    SUM(admission_cost) AS total_revenue,&lt;br&gt;
    DENSE_RANK() OVER (&lt;br&gt;
        ORDER BY SUM(admission_cost) DESC&lt;br&gt;
    ) AS dense_revenue_rank&lt;br&gt;
FROM admissions&lt;br&gt;
GROUP BY doctor_id;&lt;/p&gt;

&lt;h4&gt;
  
  
  Ntile().
&lt;/h4&gt;

&lt;p&gt;Function&lt;/p&gt;

&lt;p&gt;Split the ordered rows into a certain number of roughly equal buckets.&lt;/p&gt;

&lt;p&gt;Usage&lt;/p&gt;

&lt;p&gt;Hospitals can split patients into 4 categories based on cost. Doctors can be compared based on the quartile of work they do. Patients can be split into groups based on how long they stay in.&lt;/p&gt;

&lt;p&gt;SELECT&lt;br&gt;
    patient_id,&lt;br&gt;
    admission_cost,&lt;br&gt;
    NTILE(4) OVER (&lt;br&gt;
        ORDER BY admission_cost&lt;br&gt;
    ) AS cost_quartile&lt;br&gt;
FROM admissions;&lt;/p&gt;

&lt;h4&gt;
  
  
  Lag().
&lt;/h4&gt;

&lt;p&gt;What it does: Retrieves a value from a preceding row in the ordered window without requiring a self-join.&lt;/p&gt;

&lt;p&gt;Why it is used: It helps compare a patient's current admission cost with their previous admission cost or compare a department's monthly revenue with the previous month.&lt;/p&gt;

&lt;p&gt;SELECT&lt;br&gt;
    patient_id,&lt;br&gt;
    admission_date,&lt;br&gt;
    admission_cost,&lt;br&gt;
    LAG(admission_cost) OVER (&lt;br&gt;
        PARTITION BY patient_id&lt;br&gt;
        ORDER BY admission_date, admission_id&lt;br&gt;
    ) AS previous_admission_cost&lt;br&gt;
FROM admissions;&lt;/p&gt;

&lt;h4&gt;
  
  
  Lead().
&lt;/h4&gt;

&lt;p&gt;What it does: Retrieves a value from a following row in the ordered window.&lt;/p&gt;

&lt;p&gt;Why it is used: It can help examine the next scheduled appointment, the next admission, or a future record in a patient's treatment history.&lt;/p&gt;

&lt;p&gt;SELECT&lt;br&gt;
    patient_id,&lt;br&gt;
    admission_date,&lt;br&gt;
    admission_cost,&lt;br&gt;
    LEAD(admission_cost) OVER (&lt;br&gt;
        PARTITION BY patient_id&lt;br&gt;
        ORDER BY admission_date, admission_id&lt;br&gt;
    ) AS next_admission_cost&lt;br&gt;
FROM admissions;&lt;/p&gt;

&lt;h2&gt;
  
  
  2. SQL Joins.
&lt;/h2&gt;

&lt;h3&gt;
  
  
  2.1 What are SQL joins?
&lt;/h3&gt;

&lt;p&gt;A Join in SQL is used to combine data from two or more tables. In relational databases, data is stored in tables to avoid duplication.&lt;/p&gt;

&lt;p&gt;For example a hospital could have a patients table containing information about their patients, a doctors table containing information about their doctors and an admissions table containing information about when they admitted them. Using a join you can write a query to bring together all of this data (patients name, doctors name and admittance date).&lt;/p&gt;

&lt;h2&gt;
  
  
  Types of Joins.
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Inner join.
&lt;/h3&gt;

&lt;p&gt;Function:&lt;br&gt;
Returns only rows which meet the joining criteria of both tables.&lt;/p&gt;

&lt;p&gt;Use:&lt;br&gt;
If you wish to produce a report which only contains admissions which have an existing patient record this function can be used.&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
SELECT&lt;br&gt;
    p.patient_id,&lt;br&gt;
    p.patient_name,&lt;br&gt;
    a.admission_id,&lt;br&gt;
    a.admission_cost&lt;br&gt;
FROM patients AS p&lt;br&gt;
INNER JOIN admissions AS a&lt;br&gt;
    ON p.patient_id = a.patient_id;&lt;/p&gt;

&lt;h3&gt;
  
  
  Left join.
&lt;/h3&gt;

&lt;p&gt;Function: Returns all the rows from the left table, and any matching rows from the right table. If there are no matching rows in the right table then all columns in the right table will be NULL.&lt;/p&gt;

&lt;p&gt;Use: Can be useful in situations where Hospital Management want to see a list of all the patients that are registered with them even if they have never been admitted.&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
SELECT&lt;br&gt;
    p.patient_id,&lt;br&gt;
    p.patient_name,&lt;br&gt;
    a.admission_id,&lt;br&gt;
    a.admission_cost&lt;br&gt;
FROM patients AS p&lt;br&gt;
LEFT JOIN admissions AS a&lt;br&gt;
    ON p.patient_id = a.patient_id;&lt;/p&gt;

&lt;h3&gt;
  
  
  Right join.
&lt;/h3&gt;

&lt;p&gt;It will return all records from the right table and any matched records from the left table. If there is no match then the columns from the left table will show as NULL.&lt;/p&gt;

&lt;p&gt;This can be useful if we want to keep all admission records in the hospital.&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
SELECT&lt;br&gt;
    p.patient_id,&lt;br&gt;
    p.patient_name,&lt;br&gt;
    a.admission_id,&lt;br&gt;
    a.admission_cost&lt;br&gt;
FROM patients AS p&lt;br&gt;
RIGHT JOIN admissions AS a&lt;br&gt;
    ON p.patient_id = a.patient_id;&lt;/p&gt;

&lt;h3&gt;
  
  
  Full outer join.
&lt;/h3&gt;

&lt;p&gt;What it does: Returns matching rows and any unmatched rows from both tables. Any missing rows will show as NULL.&lt;/p&gt;

&lt;p&gt;Why it can be used: To help match patients to admissions, orphan admissions and patients with no admissions.&lt;/p&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;p&gt;SELECT&lt;br&gt;
    p.patient_id,&lt;br&gt;
    p.patient_name,&lt;br&gt;
    a.admission_id,&lt;br&gt;
    a.admission_cost&lt;br&gt;
FROM patients AS p&lt;br&gt;
FULL OUTER JOIN admissions AS a&lt;br&gt;
    ON p.patient_id = a.patient_id;&lt;/p&gt;

&lt;h3&gt;
  
  
  Cross Join.
&lt;/h3&gt;

&lt;p&gt;What it does: This function creates a Cartesian product of two tables. Basically it matches every row of the first table to every row in the second table.&lt;/p&gt;

&lt;p&gt;Why you would want to do this: Can be useful to create combinations, for example all departments in a hospital with each month they reported.&lt;/p&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;p&gt;SELECT&lt;br&gt;
    d.department_name,&lt;br&gt;
    m.month_name&lt;br&gt;
FROM departments AS d&lt;br&gt;
CROSS JOIN (&lt;br&gt;
    SELECT 'January' AS month_name&lt;br&gt;
    UNION ALL&lt;br&gt;
    SELECT 'February'&lt;br&gt;
) AS m;&lt;/p&gt;

&lt;h3&gt;
  
  
  Self Join.
&lt;/h3&gt;

&lt;p&gt;What it does:&lt;/p&gt;

&lt;p&gt;It joins a table with itself but with different aliases.&lt;/p&gt;

&lt;p&gt;When would I use it:&lt;/p&gt;

&lt;p&gt;You can use this when you have a hierarchical relationship between pieces of data, for example joining hospital staff to their manager.&lt;/p&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;p&gt;SELECT&lt;br&gt;
    e.employee_name AS employee,&lt;br&gt;
    m.employee_name AS manager&lt;br&gt;
FROM employees AS e&lt;br&gt;
LEFT JOIN employees AS m&lt;br&gt;
    ON e.manager_id = m.employee_id;&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Common Table Expressions (CTEs).
&lt;/h2&gt;

&lt;h3&gt;
  
  
  What is a CTE?
&lt;/h3&gt;

&lt;p&gt;A Common Table Expression (CTE) is a temporary result set that can be referenced by name in a statement using the WITH clause.&lt;/p&gt;

&lt;p&gt;They help break down complicated SQL queries into simpler manageable parts as they let us create some intermediate results to be referred to by their name.&lt;/p&gt;

&lt;p&gt;In a hospital setting CTEs can be used to aggregate admission information, find out how much money departments make, see which cases are most expensive and produce reports in a hierarchy.&lt;/p&gt;

&lt;h4&gt;
  
  
  3.1 Basic CTE.
&lt;/h4&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;p&gt;WITH patient_costs AS (&lt;br&gt;
    SELECT&lt;br&gt;
        patient_id,&lt;br&gt;
        SUM(admission_cost) AS total_cost&lt;br&gt;
    FROM admissions&lt;br&gt;
    GROUP BY patient_id&lt;br&gt;
)&lt;br&gt;
SELECT&lt;br&gt;
    patient_id,&lt;br&gt;
    total_cost&lt;br&gt;
FROM patient_costs&lt;br&gt;
WHERE total_cost &amp;gt; 20000;&lt;/p&gt;

&lt;p&gt;Expalantion:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The CTE groups the data by patient into a table called patient_costs&lt;/li&gt;
&lt;li&gt;Calculates the total admission cost for each patient using SUM(admission_cost).&lt;/li&gt;
&lt;li&gt;Selects only those patients with an admission cost &amp;gt; KSh 20,000
We would expect this to return a list of patient IDs and how much they spent on admission (only those that spent more than the threshold)
This CTE can make the query easier to read.&lt;/li&gt;
&lt;/ol&gt;

&lt;h4&gt;
  
  
  Multiple CTE.
&lt;/h4&gt;

&lt;p&gt;A query can define multiple CTEs, allowing each step to build on a previous one.&lt;/p&gt;

&lt;p&gt;Example: &lt;/p&gt;

&lt;p&gt;WITH patient_costs AS (&lt;br&gt;
    SELECT&lt;br&gt;
        patient_id,&lt;br&gt;
        SUM(admission_cost) AS total_cost&lt;br&gt;
    FROM admissions&lt;br&gt;
    GROUP BY patient_id&lt;br&gt;
),&lt;br&gt;
ranked_patients AS (&lt;br&gt;
    SELECT&lt;br&gt;
        patient_id,&lt;br&gt;
        total_cost,&lt;br&gt;
        DENSE_RANK() OVER (&lt;br&gt;
            ORDER BY total_cost DESC&lt;br&gt;
        ) AS cost_rank&lt;br&gt;
    FROM patient_costs&lt;br&gt;
)&lt;br&gt;
SELECT&lt;br&gt;
    patient_id,&lt;br&gt;
    total_cost,&lt;br&gt;
    cost_rank&lt;br&gt;
FROM ranked_patients&lt;br&gt;
WHERE cost_rank &amp;lt;= 5&lt;br&gt;
ORDER BY cost_rank, patient_id;&lt;/p&gt;

&lt;p&gt;Explanation:&lt;br&gt;
patient_costs will calculate the total cost for each patient.&lt;br&gt;
ranked_patients will assign a dense rank to the patients based on their total cost.&lt;br&gt;
The final query will return the top 5 ranked patients.&lt;br&gt;
We expect to see a list of the most expensive patients. As it uses dense rankings there may be more than 5 rows returned as some patients may tie in the top 5 unique rankings.&lt;/p&gt;

&lt;p&gt;This can be useful to provide to management. Each part has a clear purpose.&lt;/p&gt;

&lt;h4&gt;
  
  
  Recursive CTEs.
&lt;/h4&gt;

&lt;p&gt;A recursive CTE uses recursion to query hierarchical or sequential data. This is often used to navigate organisational structures or category trees.&lt;/p&gt;

&lt;p&gt;A recursive CTE will usually consist of:&lt;br&gt;
An anchor member that provides initial data.&lt;br&gt;
A recursive member which queries the previous result to get the next level of data.&lt;br&gt;
A terminating condition where no further data is returned.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. SQL Subqueries.
&lt;/h2&gt;

&lt;h3&gt;
  
  
  What is a subquery?
&lt;/h3&gt;

&lt;p&gt;This is a query within another query in SQL. This can help you to use the results of one query as a value, list of values or a table for another query.&lt;/p&gt;

&lt;p&gt;Subqueries can help you compare values with averages, filter out information using a relevant set of data or perform calculations on your data to give you your final results. This can be useful in hospital reports.&lt;/p&gt;

&lt;h4&gt;
  
  
  4.1 Scalar subqueries.
&lt;/h4&gt;

&lt;p&gt;What they do: Return a single value (usually 1 row and 1 column)&lt;/p&gt;

&lt;p&gt;Why they are used: To compare each record against a single calculated value (such as the average cost of admission in the whole hospital).&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
SELECT&lt;br&gt;
    admission_id,&lt;br&gt;
    patient_id,&lt;br&gt;
    admission_cost&lt;br&gt;
FROM admissions&lt;br&gt;
WHERE admission_cost &amp;gt; (&lt;br&gt;
    SELECT AVG(admission_cost)&lt;br&gt;
    FROM admissions&lt;br&gt;
);&lt;/p&gt;

&lt;p&gt;The inner query finds the average cost of admissions. The outer query then shows all admissions where the cost is higher than the average.&lt;/p&gt;

&lt;p&gt;Output:&lt;/p&gt;

&lt;p&gt;Admissions that have an admission cost higher than the average of all admissions.&lt;/p&gt;

&lt;p&gt;As these queries only return a single row of data, if they return more than one row in a situation where only 1 should be returned, many SQL systems will throw an error. If they return zero rows, they will usually return a NULL value.&lt;/p&gt;

&lt;h4&gt;
  
  
  4.2 Non-correlated subqueries.
&lt;/h4&gt;

&lt;p&gt;They are executed outside of the current row context of the outer query because their query does not refer to any columns&lt;/p&gt;

&lt;p&gt;Why use them? To pre-calculate a value such as a threshold or find a list of relevant IDs before applying filters in the outer query.&lt;/p&gt;

&lt;h4&gt;
  
  
  4.3 Correlated subqueries.
&lt;/h4&gt;

&lt;p&gt;What they do: You will have a reference to a column from the outside query. This means the outcome of the subquery will change based on the current row from the outer query.&lt;/p&gt;

&lt;p&gt;Why they are useful: This can be useful when you want to compare a record against other records within the group. For instance looking at admissions where the cost is higher than the average for that department.&lt;/p&gt;

&lt;h4&gt;
  
  
  4.4 Nested subqueries.
&lt;/h4&gt;

&lt;p&gt;This allows you to nest subqueries, so you can have multiple levels of filtering/calculation.&lt;/p&gt;

&lt;p&gt;They are useful when you need to find a group and compare data within this group or to it.&lt;/p&gt;

&lt;p&gt;Find patients with an admission in the department with the highest average admission cost.&lt;/p&gt;

&lt;h4&gt;
  
  
  4.5 Subqueries using IN.
&lt;/h4&gt;

&lt;p&gt;Purpose: To test if a value exists in a list of values returned from a subquery.&lt;/p&gt;

&lt;p&gt;Use: This can be useful if you want to find patients that are part of a group e.g. Patients admitted to a certain department.&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
SELECT&lt;br&gt;
    patient_id,&lt;br&gt;
    patient_name&lt;br&gt;
FROM patients&lt;br&gt;
WHERE patient_id IN (&lt;br&gt;
    SELECT patient_id&lt;br&gt;
    FROM admissions&lt;br&gt;
    WHERE admission_cost &amp;gt; 20000&lt;br&gt;
);&lt;/p&gt;

&lt;h4&gt;
  
  
  4.6 Subqueries using EXISTS.
&lt;/h4&gt;

&lt;p&gt;Functionality:&lt;br&gt;
Checks that the sub-query returns at least one row.&lt;/p&gt;

&lt;p&gt;Usage:&lt;br&gt;
Useful for checking there are patients with at least one admission or departments with at least one related doctor.&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
SELECT&lt;br&gt;
    p.patient_id,&lt;br&gt;
    p.patient_name&lt;br&gt;
FROM patients AS p&lt;br&gt;
WHERE EXISTS (&lt;br&gt;
    SELECT 1&lt;br&gt;
    FROM admissions AS a&lt;br&gt;
    WHERE a.patient_id = p.patient_id&lt;br&gt;
);&lt;/p&gt;

&lt;h4&gt;
  
  
  Subquery using ANY.
&lt;/h4&gt;

&lt;p&gt;What it means: Compares a value to one or more values in a subquery. At least one of the comparison conditions must evaluate to TRUE.&lt;/p&gt;

&lt;p&gt;Why you would use it: You could use this to find admissions that had higher costs than at least one department's average.&lt;/p&gt;

&lt;h4&gt;
  
  
  Subquery using ALL.
&lt;/h4&gt;

&lt;p&gt;What it does: Compares a value with every value returned by a subquery.&lt;/p&gt;

&lt;p&gt;Why it is used: It can identify admissions whose costs exceed the averages of all departments.&lt;/p&gt;

&lt;h2&gt;
  
  
  COnclusion.
&lt;/h2&gt;

&lt;p&gt;SQL window functions, joins, CTEs and subqueries are vital to analyse relational data. They all have their own uses but can be combined to perform complex analysis.&lt;br&gt;
Window functions can be used to rank, total up, average and compare data without losing any rows of data.&lt;br&gt;
Joins allow you to join together related data from multiple tables. This helps you find matching and non-matching data.&lt;br&gt;
CTEs help break down complex queries into digestible parts. They can also be used for recursive analysis of hierarchical data.&lt;br&gt;
Subqueries allow you to use the output of one query within another. Helping filter, compare and calculate.&lt;br&gt;
These concepts can be used in a Hospital setting to answer questions such as how many patients were admitted, how much each department costs, how much was spent on treatments and more. As a data scientist/data engineer it is useful to understand these concepts as you need to make sure you are pulling back the correct information, understanding the relationships between data and performing the correct calculations to get reliable analysis.&lt;/p&gt;

&lt;p&gt;The most important thing is not knowing the SQL syntax but understanding what you are trying to do, what type of query to write and correctly interpreting your results.&lt;/p&gt;

</description>
      <category>data</category>
      <category>database</category>
      <category>sql</category>
      <category>tutorial</category>
    </item>
    <item>
      <title># HOW TO EMBED A POWER BI REPORT INTO A WEBSITE.</title>
      <dc:creator>Nyamatari Brian</dc:creator>
      <pubDate>Thu, 29 Oct 2026 09:31:58 +0000</pubDate>
      <link>https://dev.to/nyamatari_brian_c41e0c389/-how-toembed-a-power-bi-report-into-a-website-bko</link>
      <guid>https://dev.to/nyamatari_brian_c41e0c389/-how-toembed-a-power-bi-report-into-a-website-bko</guid>
      <description>&lt;h2&gt;
  
  
  Introduction.
&lt;/h2&gt;

&lt;p&gt;As we all know Power BI is a powerful analytics tool developed by Microsoft. The power it has usually enables us visualize data and give insights through interactive dashboards and give reports. This helps the transformation of raw data into meaningful information for better decision making in any field.&lt;/p&gt;

&lt;p&gt;Here we are going to learn how to publish Power BI reports and embed it into a website.&lt;/p&gt;

&lt;h3&gt;
  
  
  Creating a workspace.
&lt;/h3&gt;

&lt;p&gt;A workspace in PowerBi is a space where you store and manage your datasets like reports and dashboards.&lt;/p&gt;

&lt;h4&gt;
  
  
  Steps:
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;Go to your PowerBi app.&lt;/li&gt;
&lt;li&gt;Click on workspaces in the left menu.&lt;/li&gt;
&lt;li&gt;Click Create workspace&lt;/li&gt;
&lt;li&gt;Enter a name of your choice.&lt;/li&gt;
&lt;li&gt;Click on save.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Uploading and publishing your reports.
&lt;/h3&gt;

&lt;p&gt;After creating your report in Power BI, one needs to publish it online.&lt;/p&gt;

&lt;h4&gt;
  
  
  Steps:
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;Open your '.pbix' file in Powerbi.&lt;/li&gt;
&lt;li&gt;Click on Publish from the home tab.&lt;/li&gt;
&lt;li&gt;Sign in into your account if required.&lt;/li&gt;
&lt;li&gt;Choose your workspace.&lt;/li&gt;
&lt;li&gt;Click on select.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Generating the embed code.
&lt;/h3&gt;

&lt;p&gt;In order to display your report on a website, you need an embed link.&lt;/p&gt;

&lt;h4&gt;
  
  
  Steps:
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;Open Powerbi service.&lt;/li&gt;
&lt;li&gt; Go to your workspace.&lt;/li&gt;
&lt;li&gt;Open the report of your choice.&lt;/li&gt;
&lt;li&gt;Click on file then embed report and publish to web.&lt;/li&gt;
&lt;li&gt;Create the embed code.&lt;/li&gt;
&lt;li&gt;Copy the iframe code.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Embedding the report on a website.
&lt;/h3&gt;

&lt;p&gt;One can embed a report using HTML.&lt;/p&gt;

&lt;h3&gt;
  
  
  Example:
&lt;/h3&gt;

&lt;h3&gt;
  
  
  Embedding a specific page.
&lt;/h3&gt;

&lt;p&gt;To load the specifications of a report on a page load, append the pagename parameter to the src url:&lt;/p&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;p&gt;src="&lt;a href="https://app.powerbi.com/reportEmbed?reportId=YOUR_REPORT_ID&amp;amp;pageName=ReportSection2" rel="noopener noreferrer"&gt;https://app.powerbi.com/reportEmbed?reportId=YOUR_REPORT_ID&amp;amp;pageName=ReportSection2&lt;/a&gt;"&lt;/p&gt;

&lt;h3&gt;
  
  
  Important insights and best  practice.
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Applying Row-Level Security. (RLS)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Even before publishing the dashboard to a public or semi- public audience, define RLS roles in powerbi to restrict which rows of the fact, customer or location tables individuals users can see&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Use Premium capacity for scale. &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Powerbi premium lets you embed reports without requiring every viewer to have a pro license. This is good for public facing websites where visitors volumes are unknown.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Schedule data refresh.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The data scales in the dashboard is statistical unit refreshed. One needs to set up a data gateway and configure a schedule refresh in the preferred choice of the one doing it in the workspace settings so the embedded reports always reflect current figures.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Make the embed responsive.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;To ensure it is responsive always us the padding-top wrapper approach so that the dashboards scales cleanly on mobile and desktop screens without horizontal scrollbars.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Control which page loads first.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The use pagename URL parameter to decide whether visitors land on the summary dashboards, the profit margin drill-down depending on your audience.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Monitor usage.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In every usage one must use the Usage metrics report in the workspace to track how many users view embedded report and which pages they visit most and peak viewing times.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Secure sensitive data.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In every work done one must secure their  data which involves scenarios whereby users embed power bi. This uses a service principal and generates token server-side, keeping data protected behind authentication.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion.
&lt;/h2&gt;

&lt;p&gt;This guide started from raw data to finally embedding powerbi.&lt;/p&gt;

</description>
      <category>microsoft</category>
      <category>webdev</category>
      <category>analytics</category>
      <category>tutorial</category>
    </item>
    <item>
      <title># Understanding Data Modeling in PowerBI: Joins, Relationship and Schemas.</title>
      <dc:creator>Nyamatari Brian</dc:creator>
      <pubDate>Sun, 05 Apr 2026 08:01:39 +0000</pubDate>
      <link>https://dev.to/nyamatari_brian_c41e0c389/-understanding-data-modeling-in-powerbi-joins-relationship-and-schemas-1imn</link>
      <guid>https://dev.to/nyamatari_brian_c41e0c389/-understanding-data-modeling-in-powerbi-joins-relationship-and-schemas-1imn</guid>
      <description>&lt;h2&gt;
  
  
  Introduction.
&lt;/h2&gt;

&lt;p&gt;Data Modeling is a good backbone of making Data Science and Analytics in PowerBI very successful. We are going to look into:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Data modeling fundamentals.&lt;/li&gt;
&lt;li&gt;SQL Joins.&lt;/li&gt;
&lt;li&gt;PowerBI relationships.&lt;/li&gt;
&lt;li&gt;Facts vs deimension tables.&lt;/li&gt;
&lt;li&gt;Data schema.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The big Question; WHAT is data modeling.
&lt;/h2&gt;

&lt;p&gt;Well Data modeling is the process of organizing and structuring data from multiple sources into a logical format for analysis.&lt;/p&gt;

&lt;p&gt;Here it is all about:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The Table connection.&lt;/li&gt;
&lt;li&gt;Defining relationships.&lt;/li&gt;
&lt;li&gt;Structuring data into facts and dimension tables.&lt;/li&gt;
&lt;li&gt;Optimizing performance.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Just imagine all this like making your data easy and smooth to read and interpret.&lt;/p&gt;

&lt;h2&gt;
  
  
  SQL joins.
&lt;/h2&gt;

&lt;p&gt;This is basically where we use joins to make data jointed from multiple tables using a common column.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. INNER JOIN.
&lt;/h3&gt;

&lt;p&gt;This only returns matching records in both tables.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. LEFT JOIN.
&lt;/h3&gt;

&lt;p&gt;Here in the records are all returned from left side of the table and matching the records from the right.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. RIGHT JOIN.
&lt;/h3&gt;

&lt;p&gt;This is basically the vice versa of LEFT JOIN, the records from the right table and matching ones from the left.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. FULL OUTER JOIN.
&lt;/h3&gt;

&lt;p&gt;This returns all records from both tables whether matched or unmatched.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. LEFT ANTI JOIN.
&lt;/h3&gt;

&lt;p&gt;The returning record in the table that do not exist in the right.&lt;/p&gt;

&lt;h3&gt;
  
  
  6. RIGHT ANTI JOIN.
&lt;/h3&gt;

&lt;p&gt;The returns records in the right table that do not exist in the left.&lt;/p&gt;

&lt;h2&gt;
  
  
  Steps in the creation of join in PowerBI.
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Open PowerBi desktop.&lt;/li&gt;
&lt;li&gt;Select the datasets you want to use.&lt;/li&gt;
&lt;li&gt;Click on transform data.&lt;/li&gt;
&lt;li&gt;Select a table.&lt;/li&gt;
&lt;li&gt;Click on merge queries.&lt;/li&gt;
&lt;li&gt;Choose the second table.&lt;/li&gt;
&lt;li&gt;Select on matching columns.&lt;/li&gt;
&lt;li&gt;Choose the join type of your choice.&lt;/li&gt;
&lt;li&gt;Click OK and expand the columns&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  PowerBI Relationships.
&lt;/h2&gt;

&lt;p&gt;The datasets can connects to each other without ever merging them.&lt;/p&gt;

&lt;h3&gt;
  
  
  Types of Relationships
&lt;/h3&gt;

&lt;h4&gt;
  
  
  1. One to many. (1:M)
&lt;/h4&gt;

&lt;p&gt;Here is where a table from dataset A relates to many tables in dataset B. Example; A customer can make many orders.&lt;/p&gt;

&lt;h4&gt;
  
  
  2. One to One.(1:1)
&lt;/h4&gt;

&lt;p&gt;In this relationship the table matches exactly one in another table.&lt;/p&gt;

&lt;h4&gt;
  
  
  3. Many to Many.(M:M)
&lt;/h4&gt;

&lt;p&gt;Here both tables from datasets contains duplicate values.&lt;/p&gt;

&lt;h3&gt;
  
  
  Key concepts.
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Cardinality.
&lt;/h4&gt;

&lt;p&gt;This is where tables are defined by how they relate;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;One-to-many.&lt;/li&gt;
&lt;li&gt;Many-to-many.&lt;/li&gt;
&lt;li&gt;One-to-one.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Cross filter direction.
&lt;/h4&gt;

&lt;p&gt;In this we get to understand;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Both directions and allows two way filtering but may cause ambiguty.&lt;br&gt;
Single direction.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h4&gt;
  
  
  Active and inactive relationships.
&lt;/h4&gt;

&lt;p&gt;In this relationship the active is usually the default and indirect usually requires the DAX.(User relationship)&lt;/p&gt;

&lt;h4&gt;
  
  
  Facts vs Dimension Tables.
&lt;/h4&gt;

&lt;h5&gt;
  
  
  Fact Table.
&lt;/h5&gt;

&lt;p&gt;This is where it contains data that can be measured.&lt;br&gt;
Example: Sales Amount.&lt;/p&gt;

&lt;h5&gt;
  
  
  Dimension Table.
&lt;/h5&gt;

&lt;p&gt;Here the data is descriptive.&lt;br&gt;
Example: Name of a customer.&lt;/p&gt;

&lt;h2&gt;
  
  
  DATA MODELLING SCHEMAS.
&lt;/h2&gt;

&lt;p&gt;They are;&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Star Schema.
&lt;/h3&gt;

&lt;p&gt;Structure:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;One Central fact table.&lt;/li&gt;
&lt;li&gt;Multiple dimension tables.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  2. Snowflake Schema.
&lt;/h3&gt;

&lt;p&gt;They usually normalize structures where dimensions are split.&lt;br&gt;
It has an advantage of saving storage.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Flat Table.
&lt;/h3&gt;

&lt;p&gt;In this schema all the data is stored in one table.&lt;br&gt;
It is very simple but also has poor performance on large datasets.&lt;/p&gt;

&lt;h2&gt;
  
  
  CONCLUSION.
&lt;/h2&gt;

&lt;p&gt;Data modelling in PowerBI is essential for building accurate and high-performing dashboards. By understanding joins, relationships, schemas and table structures you can create models that are both efficient and scalable.&lt;/p&gt;

</description>
      <category>dataengineering</category>
      <category>datascience</category>
      <category>microsoft</category>
      <category>sql</category>
    </item>
    <item>
      <title>How Excel is Used in Real-World Data Analysis.</title>
      <dc:creator>Nyamatari Brian</dc:creator>
      <pubDate>Sun, 29 Mar 2026 03:51:15 +0000</pubDate>
      <link>https://dev.to/nyamatari_brian_c41e0c389/how-excel-is-used-in-real-world-data-analysis-18cm</link>
      <guid>https://dev.to/nyamatari_brian_c41e0c389/how-excel-is-used-in-real-world-data-analysis-18cm</guid>
      <description>&lt;h1&gt;
  
  
  How Excel is Used in Real-World Data Analysis
&lt;/h1&gt;

&lt;h2&gt;
  
  
  INTRODUCTION.
&lt;/h2&gt;

&lt;p&gt;In the current word Data is becoming daily talk in every business and it is becoming today's world currency. One of the tools used in the data world is Microsoft Excel. It is widely used in business, hospitals and finacial for analytics. The data analytics are used to make the organizational decision making and strategic moves.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Excel.
&lt;/h2&gt;

&lt;p&gt;Microsoft Excel is a tool used for organizing, analyzing, and visualizing data. In Excel they use a simple interface of rows and columns for storage, creating presentation dashboards and calculate the datasets.&lt;/p&gt;

&lt;p&gt;Eventhough there are other tools for similar work like powerBi and python, Excel still remains to be the easiest hence more people use it more oftenly.&lt;/p&gt;

&lt;h2&gt;
  
  
  Real world scenarios where we use Excel.
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Business Analysis.
&lt;/h3&gt;

&lt;p&gt;In Businesses they collect data for example they can collectd how many items have been bought today or how many products are used oftenly. As a data scientist you can use this this to keep track of sales and also check for trends i your business.In the business they can track:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Keep daily, weekly and monthly sales.&lt;/li&gt;
&lt;li&gt;The data can be used to compare which products are more used to save on cost.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This data will be evaluated by the business team which will help them make good decisions for the business.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbieuxpkqkfd8umofq25a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbieuxpkqkfd8umofq25a.png" alt="Business Analysis" width="800" height="419"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Financial management.
&lt;/h3&gt;

&lt;p&gt;Most financial analysis people use Excel for keeping, budgeting and creating financial reporting. In organizations they can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create and keep track of expenses.&lt;/li&gt;
&lt;li&gt;Forecasting future income and cost.&lt;/li&gt;
&lt;li&gt;Create budgets.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjeji2hmnb76nn1fn7hny.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjeji2hmnb76nn1fn7hny.jpg" alt="Financial Management Report." width="800" height="450"&gt;&lt;/a&gt;cial analysis people use Excel for keeping, budgeting and creating financial reporting. In organizations they can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create and keep track of expenses.&lt;/li&gt;
&lt;li&gt;Forecasting future income and cost.&lt;/li&gt;
&lt;li&gt;Create budgets.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Data cleansing.
&lt;/h3&gt;

&lt;p&gt;Sometimes it can be human error to duplicate data. Here one needs to clean same duplicate data to ensure accurate analyzation. Excel can be used by:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Helps in removing the duplicates in the data set.&lt;/li&gt;
&lt;li&gt;Helps in handling the values that are missing.&lt;/li&gt;
&lt;li&gt;Helps in sorting out and filtration of the data set.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Excel data analyzing formulas.
&lt;/h2&gt;

&lt;p&gt;We use various formulas in analyzing data properly they include:&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Logical Formulas.
&lt;/h3&gt;

&lt;p&gt;This are are used to compare values and return a result of either TRUE or FALSE.&lt;/p&gt;

&lt;p&gt;They include:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Operator&lt;/th&gt;
&lt;th&gt;Meaning&lt;/th&gt;
&lt;th&gt;Example&lt;/th&gt;
&lt;th&gt;Result&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;=&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Equal to&lt;/td&gt;
&lt;td&gt;&lt;code&gt;=A1 = B1&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;TRUE if equal&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;&amp;lt;&amp;gt;&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Not equal to&lt;/td&gt;
&lt;td&gt;&lt;code&gt;=A1 &amp;lt;&amp;gt; B1&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;TRUE if not equal&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;&amp;gt;&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Greater than&lt;/td&gt;
&lt;td&gt;&lt;code&gt;=A1 &amp;gt; B1&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;TRUE if A1 is bigger&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;&amp;lt;&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Less than&lt;/td&gt;
&lt;td&gt;&lt;code&gt;=A1 &amp;lt; B1&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;TRUE if A1 is smaller&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;&amp;gt;=&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Greater than or equal to&lt;/td&gt;
&lt;td&gt;&lt;code&gt;=A1 &amp;gt;= B1&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;TRUE if A1 ≥ B1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;&amp;lt;=&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Less than or equal to&lt;/td&gt;
&lt;td&gt;&lt;code&gt;=A1 &amp;lt;= B1&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;TRUE if A1 ≤ B1&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  2. Arithmetic.
&lt;/h3&gt;

&lt;p&gt;This are the day to day formula.&lt;br&gt;
they include;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Additional.&lt;/li&gt;
&lt;li&gt;Subtraction.&lt;/li&gt;
&lt;li&gt;Multiplication.&lt;/li&gt;
&lt;li&gt;Division.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  3. Text.
&lt;/h3&gt;

&lt;p&gt;This are used in words in Excel.&lt;br&gt;
They include;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;=CONCAT(Join text)&lt;/li&gt;
&lt;li&gt;=LEFT (Get first characters)&lt;/li&gt;
&lt;li&gt;=UPPER(Convert to capital letters)&lt;/li&gt;
&lt;li&gt;=LOWER(Convert to small letters)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  4. Statistical.
&lt;/h3&gt;

&lt;p&gt;In Excel they used for analyzing data.&lt;br&gt;
They include;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;=AVERAGE&lt;/li&gt;
&lt;li&gt;=COUNT&lt;/li&gt;
&lt;li&gt;=MAX&lt;/li&gt;
&lt;li&gt;=MIN&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  5. Lookup.
&lt;/h3&gt;

&lt;p&gt;They used to find something in excel.&lt;br&gt;
They include;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;=VLOOKUP&lt;/li&gt;
&lt;li&gt;=XLOOKUP&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  6. Date and time.
&lt;/h3&gt;

&lt;p&gt;They are used for time and date in excel.&lt;br&gt;
They include;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;=TODAY()&lt;/li&gt;
&lt;li&gt;=NOW()&lt;/li&gt;
&lt;li&gt;=YEAR()&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Conclusion.
&lt;/h2&gt;

&lt;p&gt;Microsft Excel has an advantage since it makes easy use of combined and powerful featrures. It is so seemless thata beginner can very fast learn and understand the basic functions and progress to also understand pivotTables and dashboarding.&lt;/p&gt;

&lt;p&gt;Learning Excel is a skill that is helpful in the daily world that helps in decision making in most areas. Learning how to use Excel effectively is an important step for anyone looking to work with data confidently.&lt;/p&gt;

</description>
      <category>datascience</category>
    </item>
    <item>
      <title>Tools for data science and analytics installation process.</title>
      <dc:creator>Nyamatari Brian</dc:creator>
      <pubDate>Tue, 17 Mar 2026 16:32:51 +0000</pubDate>
      <link>https://dev.to/nyamatari_brian_c41e0c389/tools-for-data-science-and-analytics-installation-process-1dda</link>
      <guid>https://dev.to/nyamatari_brian_c41e0c389/tools-for-data-science-and-analytics-installation-process-1dda</guid>
      <description>&lt;h2&gt;
  
  
  Introduction.
&lt;/h2&gt;

&lt;p&gt;Before we begin with the tools we need to ask the bigger question who is a data analyst and a data scientist. First, Data analyst; they beg to answer the question WHAT HAPPENED. Second, Data Scientist; they beg to answer the question PREDICTION AND PRESCRIPTION. In the current world data is flowing all over us day by day hence. &lt;/p&gt;

&lt;h2&gt;
  
  
  How to install MYSQL and PostgreSQL.
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Introduction.
&lt;/h3&gt;

&lt;p&gt;MYSQL is just but an open-source database. It is a relational database system where one can manage, store and extract data that is structured. PostgreSQL is an advanced database system that is used for large and high performance applications which stores data.&lt;/p&gt;

&lt;h3&gt;
  
  
  Steps for Installation.
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Step 1: Downloading MYSQL.
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;Go to your web browser and search &lt;a href="https://www.mysql.com/downloads/" rel="noopener noreferrer"&gt;https://www.mysql.com/downloads/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Click on download now and download according to your laptop operating system.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0q2c4a2h5hwlbw387s9h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0q2c4a2h5hwlbw387s9h.png" alt="MySQL Downloading" width="800" height="428"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Step 2: Installation of MYSQL.
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;Open the downloaded file.&lt;/li&gt;
&lt;li&gt;Once opened choose "my server only".&lt;/li&gt;
&lt;li&gt;Set the port number to default.&lt;/li&gt;
&lt;li&gt;Create a root password then finish the configuration.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Postgre.
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Step 1: Download PostgreSql.
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Go to your browser &lt;a href="https://www.postgresql.org/download/" rel="noopener noreferrer"&gt;https://www.postgresql.org/download/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Choose your Operating system.&lt;/li&gt;
&lt;li&gt;After downloading open it then choose components for installation then click on next to continue.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftr2ccnrsjkippnrmv2ie.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftr2ccnrsjkippnrmv2ie.png" alt="PostgreSQL" width="800" height="432"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2: Configuration of PostgreSQL.
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;One will be asked to configure some essential settings which are:&lt;/li&gt;
&lt;li&gt;You will be required to set a password.&lt;/li&gt;
&lt;li&gt;You will be asked to input aport number leave it at default which is '5432'.&lt;/li&gt;
&lt;li&gt;Leave the installation at locale default settings then finish installation.&lt;/li&gt;
&lt;/ol&gt;

&lt;h1&gt;
  
  
  Installation of Excel and PowerBi.
&lt;/h1&gt;

&lt;h2&gt;
  
  
  Excel.
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Step 1: Installation.
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Go to Microsoft store on windows and look for excel then download it.&lt;/li&gt;
&lt;li&gt;After finishing the download open it and ensure it is working properly.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  PowerBi.
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Step 1: Installation.
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Go to Microsoft store on windows and look for PowerBi then download it.&lt;/li&gt;
&lt;li&gt;After the download is over open it and ensure it is working properly.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  What about for other users that is MacBook and Linux.
&lt;/h3&gt;

&lt;p&gt;One can use a Virtual machine to access this tools.&lt;/p&gt;

&lt;p&gt;### Step 1: VirtualBox.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Install VirtualBox and select for MacBook or Linux.&lt;/li&gt;
&lt;li&gt;Follow the installation instructions and the VirtualBox will be fully installed into your machine.&lt;/li&gt;
&lt;li&gt;Download windows ISO file and save in you laptop.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Step 2: Create a virtual machine.
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Open the virtualbox and then click on new.&lt;/li&gt;
&lt;li&gt;You will be required to fill;&lt;/li&gt;
&lt;li&gt;Name of the virtual machine.&lt;/li&gt;
&lt;li&gt;The Type.&lt;/li&gt;
&lt;li&gt;Version of the windows.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Step 3: Allocate virtual machine some memory.
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Choose how much RAM to give the virtual machine.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Step 4: Create the hard disk of the VM.
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Click on create a virtual hard disk now then click next.&lt;/li&gt;
&lt;li&gt;Choose Virtualbox Disk image.&lt;/li&gt;
&lt;li&gt;Choose the dynamically allocated then set size to 50GB.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Step 5: Install windows.
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Select the virtualmachine you created then click on start.&lt;/li&gt;
&lt;li&gt;You shall be prompted then select the windows ISO file that we downloaded and folow the normal windows installation steps.
3.The windows will open inside the virtual machine.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Step 6: Installation Excell and PowerBI.
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Inside the windowss viryual machine go to Microssoft Store and download both PowerBI and excel.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Step 7:Launch the application.
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Inside the Windows virtual machine you can now open;&lt;/li&gt;
&lt;li&gt;PoweBI.&lt;/li&gt;
&lt;li&gt;Excel.&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>database</category>
      <category>datascience</category>
      <category>sql</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
