<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Sql on</title><link>https://bacarotech.github.io/tags/sql/</link><description>Recent content in Sql on</description><generator>Hugo</generator><language>it</language><lastBuildDate>Wed, 25 Feb 2026 14:01:43 +0000</lastBuildDate><atom:link href="https://bacarotech.github.io/tags/sql/index.xml" rel="self" type="application/rss+xml"/><item><title>SQLLeetCode - 2356 - Number of Unique Subjects Taught by Each Teacher</title><link>https://bacarotech.github.io/blog/2026/sqlleetcode---2356---number-of-unique-subjects-taught-by-each-teacher/</link><pubDate>Wed, 25 Feb 2026 14:01:43 +0000</pubDate><guid>https://bacarotech.github.io/blog/2026/sqlleetcode---2356---number-of-unique-subjects-taught-by-each-teacher/</guid><description>&lt;p&gt;Oggi vediamo il seguente esercizio di LeetCode a tema SQL:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Write a solution to calculate the number of unique subjects each teacher teaches in the university.&lt;/p&gt;
&lt;p&gt;Return the result table in any order.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Guardando le tabelle fornite dall&amp;rsquo;esercizio si può notare che la tabella Teacher contiene le informazioni sugli insegnanti: &lt;code&gt;teacher_id&lt;/code&gt;, &lt;code&gt;subject_id&lt;/code&gt;, &lt;code&gt;dept_id&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;L&amp;rsquo;obiettivo è contare il numero di materie uniche insegnate da ciascun insegnante. Poiché un insegnante può insegnare la stessa materia in dipartimenti diversi, dobbiamo contare solo le materie distinte per ogni insegnante.&lt;/p&gt;</description></item><item><title>SQLLeetCode - 1934 - Confirmation Rate</title><link>https://bacarotech.github.io/blog/2026/sqlleetcode---1934---confirmation-rate/</link><pubDate>Wed, 25 Feb 2026 14:01:42 +0000</pubDate><guid>https://bacarotech.github.io/blog/2026/sqlleetcode---1934---confirmation-rate/</guid><description>&lt;p&gt;Oggi vediamo il seguente esercizio di LeetCode a tema SQL:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;The confirmation rate of a user is the number of &amp;lsquo;confirmed&amp;rsquo; messages divided by the total number of requested confirmation messages. The confirmation rate of a user that did not request any confirmation messages is 0. Round the confirmation rate to two decimal places.&lt;/p&gt;
&lt;p&gt;Write a solution to find the confirmation rate of each user.&lt;/p&gt;
&lt;p&gt;Return the result table in any order.&lt;/p&gt;</description></item><item><title>SQLLeetCode - 1757 - Recyclable and Low Fat Products</title><link>https://bacarotech.github.io/blog/2026/sqlleetcode---1757---recyclable-and-low-fat-products/</link><pubDate>Wed, 25 Feb 2026 14:01:41 +0000</pubDate><guid>https://bacarotech.github.io/blog/2026/sqlleetcode---1757---recyclable-and-low-fat-products/</guid><description>&lt;p&gt;Oggi vediamo il seguente esercizio di LeetCode a tema SQL:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Write a solution to find the ids of products that are both low fat and recyclable.&lt;/p&gt;
&lt;p&gt;Return the result table in any order.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Guardando le tabelle fornite dall&amp;rsquo;esercizio si può notare che la tabella Products contiene le informazioni sui prodotti: &lt;code&gt;product_id&lt;/code&gt; (ID del prodotto), &lt;code&gt;low_fats&lt;/code&gt; (indica se il prodotto è a basso contenuto di grassi - &amp;lsquo;Y&amp;rsquo; o &amp;lsquo;N&amp;rsquo;), &lt;code&gt;recyclable&lt;/code&gt; (indica se il prodotto è riciclabile - &amp;lsquo;Y&amp;rsquo; o &amp;lsquo;N&amp;rsquo;).&lt;/p&gt;</description></item><item><title>SQLLeetCode - 1731 - The Number of Employees Which Report to Each Employee</title><link>https://bacarotech.github.io/blog/2026/sqlleetcode---1731---the-number-of-employees-which-report-to-each-employee/</link><pubDate>Wed, 25 Feb 2026 14:01:40 +0000</pubDate><guid>https://bacarotech.github.io/blog/2026/sqlleetcode---1731---the-number-of-employees-which-report-to-each-employee/</guid><description>&lt;p&gt;Oggi vediamo il seguente esercizio di LeetCode a tema SQL:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Write a solution to report the ids and the names of all managers, the number of employees who report directly to them, and the average age of the reports rounded to the nearest integer.&lt;/p&gt;
&lt;p&gt;Return the result table ordered by employee_id.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Guardando le tabelle fornite dall&amp;rsquo;esercizio si può notare che la tabella Employees contiene le informazioni sui dipendenti: &lt;code&gt;employee_id&lt;/code&gt;, &lt;code&gt;name&lt;/code&gt;, &lt;code&gt;age&lt;/code&gt;, &lt;code&gt;reports_to&lt;/code&gt;.&lt;/p&gt;</description></item><item><title>SQLLeetCode - 1729 - Find Followers Count</title><link>https://bacarotech.github.io/blog/2026/sqlleetcode---1729---find-followers-count/</link><pubDate>Wed, 25 Feb 2026 14:01:39 +0000</pubDate><guid>https://bacarotech.github.io/blog/2026/sqlleetcode---1729---find-followers-count/</guid><description>&lt;p&gt;Oggi vediamo il seguente esercizio di LeetCode a tema SQL:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Write a solution that will, for each user, return the number of followers.&lt;/p&gt;
&lt;p&gt;Return the result table ordered by user_id in ascending order.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Guardando le tabelle fornite dall&amp;rsquo;esercizio si può notare che la tabella Followers contiene le informazioni sui follower: &lt;code&gt;user_id&lt;/code&gt; (l&amp;rsquo;utente che viene seguito), &lt;code&gt;follower_id&lt;/code&gt; (l&amp;rsquo;utente che segue).&lt;/p&gt;
&lt;p&gt;L&amp;rsquo;obiettivo è contare il numero di follower per ogni utente. Poiché un utente può avere più follower, dobbiamo raggruppare per user_id e contare i follower distinti.&lt;/p&gt;</description></item><item><title>SQLLeetCode - 1683 - Invalid Tweets</title><link>https://bacarotech.github.io/blog/2026/sqlleetcode---1683---invalid-tweets/</link><pubDate>Wed, 25 Feb 2026 14:01:38 +0000</pubDate><guid>https://bacarotech.github.io/blog/2026/sqlleetcode---1683---invalid-tweets/</guid><description>&lt;p&gt;Oggi vediamo il seguente esercizio di LeetCode a tema SQL:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Write a solution to find the IDs of the invalid tweets. The tweet is invalid if the number of characters used in the content of the tweet is strictly greater than 15.&lt;/p&gt;
&lt;p&gt;Return the result table in any order.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Guardando le tabelle fornite dall&amp;rsquo;esercizio si può notare che la tabella Tweets contiene le informazioni sui tweet: &lt;code&gt;tweet_id&lt;/code&gt; (ID del tweet), &lt;code&gt;content&lt;/code&gt; (contenuto del tweet).&lt;/p&gt;</description></item><item><title>SQLLeetCode - 1661 - Average Time Of Process Per Machine</title><link>https://bacarotech.github.io/blog/2026/sqlleetcode---1661---average-time-of-process-per-machine/</link><pubDate>Wed, 25 Feb 2026 14:01:37 +0000</pubDate><guid>https://bacarotech.github.io/blog/2026/sqlleetcode---1661---average-time-of-process-per-machine/</guid><description>&lt;p&gt;Oggi vediamo il seguente esercizio di LeetCode a tema SQL:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Write a solution to find the average time each machine takes to complete a process.
The time to complete a process is the &amp;rsquo;end&amp;rsquo; timestamp minus the &amp;lsquo;start&amp;rsquo; timestamp. The average time is calculated by the total time to complete every process on the machine divided by the number of processes that were run.&lt;/p&gt;
&lt;p&gt;The resulting table should have the machine_id along with the average time as processing_time, which should be rounded to 3 decimal places.&lt;/p&gt;</description></item><item><title>SQLLeetCode - 1633 - Percentage of Users Attended a Contest</title><link>https://bacarotech.github.io/blog/2026/sqlleetcode---1633---percentage-of-users-attended-a-contest/</link><pubDate>Wed, 25 Feb 2026 14:01:36 +0000</pubDate><guid>https://bacarotech.github.io/blog/2026/sqlleetcode---1633---percentage-of-users-attended-a-contest/</guid><description>&lt;p&gt;Oggi vediamo il seguente esercizio di LeetCode a tema SQL:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Write a solution to find the percentage of the users registered in each contest rounded to two decimals.&lt;/p&gt;
&lt;p&gt;Return the result table ordered by percentage in descending order. In case of a tie, order it by contest_id in ascending order.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Guardando le tabelle fornite dall&amp;rsquo;esercizio si può notare che ci sono due tabelle: Users (con user_id) e Register (con contest_id, user_id).&lt;/p&gt;</description></item><item><title>SQLLeetCode - 1581 - Customer Who Visited but Did Not Make Any Transactions</title><link>https://bacarotech.github.io/blog/2026/sqlleetcode---1581---customer-who-visited-but-did-not-make-any-transactions/</link><pubDate>Wed, 25 Feb 2026 14:01:35 +0000</pubDate><guid>https://bacarotech.github.io/blog/2026/sqlleetcode---1581---customer-who-visited-but-did-not-make-any-transactions/</guid><description>&lt;p&gt;Oggi vediamo il seguente esercizio di LeetCode a tema SQL:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Write a solution to find the IDs of the users who visited without making any transactions and the number of times they made these types of visits.&lt;/p&gt;
&lt;p&gt;Return the result table in any order.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Guardando le tabelle fornite dall&amp;rsquo;esercizio si può notare che ci sono due tabelle: Visits (con visit_id, customer_id, visit_date) e Transactions (con transaction_id, visit_id, amount).&lt;/p&gt;
&lt;p&gt;L&amp;rsquo;obiettivo è trovare i clienti che hanno visitato il negozio ma non hanno effettuato alcuna transazione e quante volte lo hanno fatto. Per farlo, dobbiamo collegare le due tabelle e identificare le visite senza transazioni associate.&lt;/p&gt;</description></item><item><title>SQLLeetCode - 1378 - Replace Employee Id With The Unique Identifier</title><link>https://bacarotech.github.io/blog/2026/sqlleetcode---1378---replace-employee-id-with-the-unique-identifier/</link><pubDate>Wed, 25 Feb 2026 14:01:34 +0000</pubDate><guid>https://bacarotech.github.io/blog/2026/sqlleetcode---1378---replace-employee-id-with-the-unique-identifier/</guid><description>&lt;p&gt;Oggi vediamo il seguente esercizio di LeetCode a tema SQL:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Write a solution to show the unique ID of each user, If a user does not have a unique ID replace just show null.&lt;/p&gt;
&lt;p&gt;Return the result table in any order.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Guardando le tabelle fornite dall&amp;rsquo;esercizio si può notare che ci sono due tabelle: Employees (con id e name) e EmployeeUNI (con id e unique_id).&lt;/p&gt;
&lt;p&gt;L&amp;rsquo;obiettivo è unire le due tabelle per ottenere per ogni dipendente il suo unique_id dalla tabella EmployeeUNI. Dobbiamo usare una LEFT JOIN perché vogliamo includere tutti i dipendenti, anche quelli che non hanno un unique_id assegnato (in quel caso unique_id sarà NULL).&lt;/p&gt;</description></item><item><title>SQLLeetCode - 1280 - Students And Examinations</title><link>https://bacarotech.github.io/blog/2026/sqlleetcode---1280---students-and-examinations/</link><pubDate>Wed, 25 Feb 2026 14:01:33 +0000</pubDate><guid>https://bacarotech.github.io/blog/2026/sqlleetcode---1280---students-and-examinations/</guid><description>&lt;p&gt;Oggi vediamo il seguente esercizio di LeetCode a tema SQL:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Write a solution to find the number of examinations each student attended for each subject.&lt;/p&gt;
&lt;p&gt;Return the result table sorted by student_id and subject_name.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Guardando le tabelle fornite dall&amp;rsquo;esercizio si può notare che ci sono tre tabelle: Students (con student_id, student_name), Subjects (con subject_name), e Examinations (con student_id, subject_name).&lt;/p&gt;
&lt;p&gt;L&amp;rsquo;obiettivo è trovare per ogni combinazione studente-materia, quante volte lo studente ha sostenuto quell&amp;rsquo;esame. Dobbiamo includere tutti gli studenti e tutte le materie, anche se lo studente non ha sostenuto alcun esame per quella materia (in quel caso il conteggio sarà 0).&lt;/p&gt;</description></item><item><title>SQLLeetCode - 1251 - Average Selling Price</title><link>https://bacarotech.github.io/blog/2026/sqlleetcode---1251---average-selling-price/</link><pubDate>Wed, 25 Feb 2026 14:01:32 +0000</pubDate><guid>https://bacarotech.github.io/blog/2026/sqlleetcode---1251---average-selling-price/</guid><description>&lt;p&gt;Oggi vediamo il seguente esercizio di LeetCode a tema SQL:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Write a solution to find the average selling price for each product. average_price should be rounded to 2 decimal places. If a product does not have any sold units, its average selling price is assumed to be 0.&lt;/p&gt;
&lt;p&gt;Return the result table in any order.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Guardando le tabelle fornite dall&amp;rsquo;esercizio si può notare che ci sono due tabelle: Prices (con product_id, start_date, end_date, price) e UnitsSold (con product_id, purchase_date, units).&lt;/p&gt;</description></item><item><title>SQLLeetCode - 1211 - Queries Quality and Percentage</title><link>https://bacarotech.github.io/blog/2026/sqlleetcode---1211---queries-quality-and-percentage/</link><pubDate>Wed, 25 Feb 2026 14:01:31 +0000</pubDate><guid>https://bacarotech.github.io/blog/2026/sqlleetcode---1211---queries-quality-and-percentage/</guid><description>&lt;p&gt;Oggi vediamo il seguente esercizio di LeetCode a tema SQL:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;We define query quality as:&lt;/p&gt;
&lt;p&gt;The average of the ratio between query rating and its position.&lt;/p&gt;
&lt;p&gt;We also define poor query percentage as:&lt;/p&gt;
&lt;p&gt;The percentage of all queries with rating less than 3.&lt;/p&gt;
&lt;p&gt;Write a solution to find each query_name, the quality and poor_query_percentage.&lt;/p&gt;
&lt;p&gt;Both quality and poor_query_percentage should be rounded to 2 decimal places.&lt;/p&gt;
&lt;p&gt;Return the result table in any order.&lt;/p&gt;</description></item><item><title>SQLLeetCode - 1193 - Monthly Transactions I</title><link>https://bacarotech.github.io/blog/2026/sqlleetcode---1193---monthly-transactions-i/</link><pubDate>Wed, 25 Feb 2026 14:01:30 +0000</pubDate><guid>https://bacarotech.github.io/blog/2026/sqlleetcode---1193---monthly-transactions-i/</guid><description>&lt;p&gt;Oggi vediamo il seguente esercizio di LeetCode a tema SQL:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Write an SQL query to find for each month and country, the number of transactions and their total amount, the number of approved transactions and their total amount.&lt;/p&gt;
&lt;p&gt;Return the result table in any order.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Guardando le tabelle fornite dall&amp;rsquo;esercizio si può notare che la tabella Transactions contiene le informazioni sulle transazioni: &lt;code&gt;id&lt;/code&gt;, &lt;code&gt;country&lt;/code&gt;, &lt;code&gt;state&lt;/code&gt; (approved/void), &lt;code&gt;amount&lt;/code&gt;, &lt;code&gt;trans_date&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;L&amp;rsquo;obiettivo è raggruppare le transazioni per mese (anno-mese) e paese, e calcolare:&lt;/p&gt;</description></item><item><title>SQLLeetCode - 1174 - Immediate Food Delivery II</title><link>https://bacarotech.github.io/blog/2026/sqlleetcode---1174---immediate-food-delivery-ii/</link><pubDate>Wed, 25 Feb 2026 14:01:29 +0000</pubDate><guid>https://bacarotech.github.io/blog/2026/sqlleetcode---1174---immediate-food-delivery-ii/</guid><description>&lt;p&gt;Oggi vediamo il seguente esercizio di LeetCode a tema SQL:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Write a solution to find the percentage of immediate orders in the first orders of all customers, rounded to 2 decimal places.&lt;/p&gt;
&lt;p&gt;Return the result table in any order.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Guardando le tabelle fornite dall&amp;rsquo;esercizio si può notare che la tabella Delivery contiene le informazioni sulle consegne: &lt;code&gt;delivery_id&lt;/code&gt;, &lt;code&gt;customer_id&lt;/code&gt;, &lt;code&gt;order_date&lt;/code&gt;, &lt;code&gt;customer_pref_delivery_date&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;L&amp;rsquo;obiettivo è calcolare la percentuale di ordini immediati rispetto al primo ordine di ogni cliente. Un ordine è considerato &amp;ldquo;immediato&amp;rdquo; se &lt;code&gt;order_date = customer_pref_delivery_date&lt;/code&gt;, cioè se la data di consegna coincide con la data preferita del cliente.&lt;/p&gt;</description></item><item><title>SQLLeetCode - 1164 - Product Price at a Given Date</title><link>https://bacarotech.github.io/blog/2026/sqlleetcode---1164---product-price-at-a-given-date/</link><pubDate>Wed, 25 Feb 2026 14:01:28 +0000</pubDate><guid>https://bacarotech.github.io/blog/2026/sqlleetcode---1164---product-price-at-a-given-date/</guid><description>&lt;p&gt;Oggi vediamo il seguente esercizio di LeetCode a tema SQL:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Write a solution to find the prices of all products on 2019-08-16. Assume the price of all products before any change is 10.&lt;/p&gt;
&lt;p&gt;Return the result table in any order.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Guardando le tabelle fornite dall&amp;rsquo;esercizio si può notare che la tabella Products contiene le informazioni sui prezzi dei prodotti: &lt;code&gt;product_id&lt;/code&gt;, &lt;code&gt;new_price&lt;/code&gt;, &lt;code&gt;change_date&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;L&amp;rsquo;obiettivo è trovare il prezzo di tutti i prodotti alla data specifica (2019-08-16). La regola è:&lt;/p&gt;</description></item><item><title>SQLLeetCode - 1148 - Article Views I</title><link>https://bacarotech.github.io/blog/2026/sqlleetcode---1148---article-views-i/</link><pubDate>Wed, 25 Feb 2026 14:01:27 +0000</pubDate><guid>https://bacarotech.github.io/blog/2026/sqlleetcode---1148---article-views-i/</guid><description>&lt;p&gt;Oggi vediamo il seguente esercizio di LeetCode a tema SQL:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Write a solution to find all the authors that viewed at least one of their own articles.&lt;/p&gt;
&lt;p&gt;Return the result table sorted by author_id.&lt;/p&gt;
&lt;p&gt;The author_id of the author is the same as the viewer_id of the view.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Guardando le tabelle fornite dall&amp;rsquo;esercizio si può notare che la tabella Views contiene le informazioni sulle visualizzazioni degli articoli: &lt;code&gt;article_id&lt;/code&gt; (ID dell&amp;rsquo;articolo), &lt;code&gt;author_id&lt;/code&gt; (ID dell&amp;rsquo;autore dell&amp;rsquo;articolo), &lt;code&gt;viewer_id&lt;/code&gt; (ID di chi ha visualizzato l&amp;rsquo;articolo), &lt;code&gt;view_date&lt;/code&gt; (data della visualizzazione).&lt;/p&gt;</description></item><item><title>SQLLeetCode - 1141 - User Activity for the Past 30 Days I</title><link>https://bacarotech.github.io/blog/2026/sqlleetcode---1141---user-activity-for-the-past-30-days-i/</link><pubDate>Wed, 25 Feb 2026 14:01:26 +0000</pubDate><guid>https://bacarotech.github.io/blog/2026/sqlleetcode---1141---user-activity-for-the-past-30-days-i/</guid><description>&lt;p&gt;Oggi vediamo il seguente esercizio di LeetCode a tema SQL:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Write a solution to report the daily active user count for a 30-day period ending on 2019-07-27 inclusively. A user became active on a given day if they made at least one activity on that day.&lt;/p&gt;
&lt;p&gt;Return the result table in any order.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Guardando le tabelle fornite dall&amp;rsquo;esercizio si può notare che la tabella Activity contiene le informazioni sulle attività degli utenti: &lt;code&gt;user_id&lt;/code&gt;, &lt;code&gt;activity_date&lt;/code&gt;, &lt;code&gt;activity_type&lt;/code&gt;, &lt;code&gt;activity_id&lt;/code&gt;.&lt;/p&gt;</description></item><item><title>SQLLeetCode - 1075 - Project Employees I</title><link>https://bacarotech.github.io/blog/2026/sqlleetcode---1075---project-employees-i/</link><pubDate>Wed, 25 Feb 2026 14:01:25 +0000</pubDate><guid>https://bacarotech.github.io/blog/2026/sqlleetcode---1075---project-employees-i/</guid><description>&lt;p&gt;Oggi vediamo il seguente esercizio di LeetCode a tema SQL:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Write a solution to report the average experience years of all the employees for each project rounded to 2 digit&lt;/p&gt;
&lt;p&gt;Return the result table in any order.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Guardando le tabelle fornite dall&amp;rsquo;esercizio si può notare che ci sono due tabelle: Project (con project_id, employee_id) e Employee (con employee_id, name, experience_years).&lt;/p&gt;
&lt;p&gt;L&amp;rsquo;obiettivo è calcolare la media degli anni di esperienza per ogni progetto. Ogni progetto può avere più dipendenti, e dobbiamo calcolare la media degli anni di esperienza di tutti i dipendenti assegnati a quel progetto.&lt;/p&gt;</description></item><item><title>SQLLeetCode - 1070 - Product Sales Analysis III</title><link>https://bacarotech.github.io/blog/2026/sqlleetcode---1070---product-sales-analysis-iii/</link><pubDate>Wed, 25 Feb 2026 14:01:24 +0000</pubDate><guid>https://bacarotech.github.io/blog/2026/sqlleetcode---1070---product-sales-analysis-iii/</guid><description>&lt;p&gt;Oggi vediamo il seguente esercizio di LeetCode a tema SQL:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Write a solution to report the first year of sales for each product id.&lt;/p&gt;
&lt;p&gt;Return the result table in any order.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Guardando le tabelle fornite dall&amp;rsquo;esercizio si può notare che la tabella Sales contiene le informazioni sulle vendite: &lt;code&gt;sale_id&lt;/code&gt;, &lt;code&gt;product_id&lt;/code&gt;, &lt;code&gt;year&lt;/code&gt;, &lt;code&gt;quantity&lt;/code&gt;, &lt;code&gt;price&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;L&amp;rsquo;obiettivo è trovare per ogni prodotto l&amp;rsquo;anno della prima vendita (l&amp;rsquo;anno più vecchio). Dobbiamo selezionare la riga con l&amp;rsquo;anno minimo per ogni prodotto.&lt;/p&gt;</description></item><item><title>SQLLeetCode - 1068 - Product Sales Analysis I</title><link>https://bacarotech.github.io/blog/2026/sqlleetcode---1068---product-sales-analysis-i/</link><pubDate>Wed, 25 Feb 2026 14:01:23 +0000</pubDate><guid>https://bacarotech.github.io/blog/2026/sqlleetcode---1068---product-sales-analysis-i/</guid><description>&lt;p&gt;Oggi vediamo il seguente esercizio di LeetCode a tema SQL:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Write a solution to report the product_name, year, and price for each sales entry in the Sales table.&lt;/p&gt;
&lt;p&gt;Return the result table in any order.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Guardando le tabelle fornite dall&amp;rsquo;esercizio si può notare che ci sono due tabelle: Sales (con sale_id, product_id, year, quantity, price) e Product (con product_id, product_name).&lt;/p&gt;
&lt;p&gt;L&amp;rsquo;obiettivo è unire le due tabelle per ottenere il nome del prodotto insieme alle informazioni di vendita. Dobbiamo collegare le tabelle usando product_id come chiave di join.&lt;/p&gt;</description></item><item><title>SQLLeetCode - 1045 - Customers Who Bought All Products</title><link>https://bacarotech.github.io/blog/2026/sqlleetcode---1045---customers-who-bought-all-products/</link><pubDate>Wed, 25 Feb 2026 14:01:22 +0000</pubDate><guid>https://bacarotech.github.io/blog/2026/sqlleetcode---1045---customers-who-bought-all-products/</guid><description>&lt;p&gt;Oggi vediamo il seguente esercizio di LeetCode a tema SQL:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Write a solution to find the customer_id of customers that bought all the products.&lt;/p&gt;
&lt;p&gt;Return the result table in any order.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Guardando le tabelle fornite dall&amp;rsquo;esercizio si può notare che ci sono due tabelle: Customer (con customer_id, product_key) e Product (con product_key).&lt;/p&gt;
&lt;p&gt;L&amp;rsquo;obiettivo è trovare i clienti che hanno acquistato tutti i prodotti disponibili. Dobbiamo confrontare il numero di prodotti acquistati da ogni cliente con il numero totale di prodotti disponibili.&lt;/p&gt;</description></item><item><title>SQLLeetCode - 620 - Not Boring Movies</title><link>https://bacarotech.github.io/blog/2026/sqlleetcode---620---not-boring-movies/</link><pubDate>Wed, 25 Feb 2026 14:01:21 +0000</pubDate><guid>https://bacarotech.github.io/blog/2026/sqlleetcode---620---not-boring-movies/</guid><description>&lt;p&gt;Oggi vediamo il seguente esercizio di LeetCode a tema SQL:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Write a solution to find the interesting movies. An interesting movie has an id that is odd, and its description is not &amp;ldquo;boring&amp;rdquo;.&lt;/p&gt;
&lt;p&gt;Return the result table sorted by rating in descending order.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Guardando le tabelle fornite dall&amp;rsquo;esercizio si può notare che la tabella Cinema (o Movie) contiene le informazioni sui film: &lt;code&gt;id&lt;/code&gt;, &lt;code&gt;movie&lt;/code&gt;, &lt;code&gt;description&lt;/code&gt;, &lt;code&gt;rating&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;L&amp;rsquo;obiettivo è trovare i film &amp;ldquo;interessanti&amp;rdquo; che soddisfano due condizioni:&lt;/p&gt;</description></item><item><title>SQLLeetCode - 619 - Biggest Single Number</title><link>https://bacarotech.github.io/blog/2026/sqlleetcode---619---biggest-single-number/</link><pubDate>Wed, 25 Feb 2026 14:01:20 +0000</pubDate><guid>https://bacarotech.github.io/blog/2026/sqlleetcode---619---biggest-single-number/</guid><description>&lt;p&gt;Oggi vediamo il seguente esercizio di LeetCode a tema SQL:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;A &amp;ldquo;single&amp;rdquo; number is a number that appears exactly once in the MyNumbers table.&lt;/p&gt;
&lt;p&gt;Write a solution to find the biggest single number. If there is no single number, the answer is null.&lt;/p&gt;
&lt;p&gt;Return the result table in any order.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Guardando le tabelle fornite dall&amp;rsquo;esercizio si può notare che la tabella MyNumbers contiene solo una colonna &lt;code&gt;num&lt;/code&gt; con vari numeri, alcuni dei quali possono essere ripetuti.&lt;/p&gt;</description></item><item><title>SQLLeetCode - 596 - Classes More Than 5 Students</title><link>https://bacarotech.github.io/blog/2026/sqlleetcode---596---classes-more-than-5-students/</link><pubDate>Wed, 25 Feb 2026 14:01:19 +0000</pubDate><guid>https://bacarotech.github.io/blog/2026/sqlleetcode---596---classes-more-than-5-students/</guid><description>&lt;p&gt;Oggi vediamo il seguente esercizio di LeetCode a tema SQL:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Write a solution to find all classes that have at least five students.&lt;/p&gt;
&lt;p&gt;Return the result table in any order.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Guardando le tabelle fornite dall&amp;rsquo;esercizio si può notare che la tabella Courses contiene le informazioni sugli studenti iscritti ai corsi: &lt;code&gt;student&lt;/code&gt; (nome dello studente), &lt;code&gt;class&lt;/code&gt; (nome del corso).&lt;/p&gt;
&lt;p&gt;L&amp;rsquo;obiettivo è trovare tutti i corsi che hanno almeno cinque studenti iscritti. Per fare ciò, dobbiamo raggruppare gli studenti per classe e contare quanti studenti ci sono in ciascun corso, poi filtrare quelli con count &amp;gt;= 5.&lt;/p&gt;</description></item><item><title>SQLLeetCode - 595 - Big Countries</title><link>https://bacarotech.github.io/blog/2026/sqlleetcode---595---big-countries/</link><pubDate>Wed, 25 Feb 2026 14:01:18 +0000</pubDate><guid>https://bacarotech.github.io/blog/2026/sqlleetcode---595---big-countries/</guid><description>&lt;p&gt;Oggi vediamo il seguente esercizio di LeetCode a tema SQL:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;A country is big if:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;it has an area of at least 3,000,000 km², or&lt;/li&gt;
&lt;li&gt;it has a population of at least 25,000,000.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Write a SQL query to report the name, population, and area of the big countries.&lt;/p&gt;
&lt;p&gt;Return the result table in any order.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Guardando le tabelle fornite dall&amp;rsquo;esercizio si può notare che la tabella World contiene le informazioni sui paesi: &lt;code&gt;name&lt;/code&gt; (nome del paese), &lt;code&gt;population&lt;/code&gt; (popolazione), &lt;code&gt;area&lt;/code&gt; (superficie in km²).&lt;/p&gt;</description></item><item><title>SQLLeetCode - 584 - Find Customer RefereeFind Customer Referee</title><link>https://bacarotech.github.io/blog/2026/sqlleetcode---584---find-customer-refereefind-customer-referee/</link><pubDate>Wed, 25 Feb 2026 14:01:17 +0000</pubDate><guid>https://bacarotech.github.io/blog/2026/sqlleetcode---584---find-customer-refereefind-customer-referee/</guid><description>&lt;p&gt;Oggi vediamo il seguente esercizio di LeetCode a tema SQL:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Find the names of the customer that are either:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;referred by any customer with id != 2.&lt;/li&gt;
&lt;li&gt;not referred by any customer.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Return the result table in any order.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Guardando le tabelle fornite dall’esercizio si può notare che la tabella Customer contiene anche il campo referee_id, che indica quale cliente ha fatto da referente (referrer) per un altro cliente. Tuttavia, questo campo può essere NULL nel caso in cui il cliente non abbia alcun referente.&lt;/p&gt;</description></item><item><title>SQLLeetCode - 577 - Employee Bonus</title><link>https://bacarotech.github.io/blog/2026/sqlleetcode---577---employee-bonus/</link><pubDate>Wed, 25 Feb 2026 14:01:16 +0000</pubDate><guid>https://bacarotech.github.io/blog/2026/sqlleetcode---577---employee-bonus/</guid><description>&lt;p&gt;Oggi vediamo il seguente esercizio di LeetCode a tema SQL:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Write a solution to report the name and bonus amount of each employee who satisfies either of the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The employee has a bonus less than 1000.&lt;/li&gt;
&lt;li&gt;The employee did not get any bonus.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Return the result table in any order.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Guardando le tabelle fornite dall’esercizio si può notare che la tabella Employee contiene tutti i dipendenti, mentre la tabella Bonus associa eventualmente un bonus a ciascun dipendente tramite empId. Tuttavia, non tutti i dipendenti hanno necessariamente un bonus assegnato.&lt;/p&gt;</description></item><item><title>SQLLeetCode - 570 - Managers with at Least 5 Direct Reports</title><link>https://bacarotech.github.io/blog/2026/sqlleetcode---570---managers-with-at-least-5-direct-reports/</link><pubDate>Wed, 25 Feb 2026 14:01:15 +0000</pubDate><guid>https://bacarotech.github.io/blog/2026/sqlleetcode---570---managers-with-at-least-5-direct-reports/</guid><description>&lt;p&gt;Oggi vediamo il seguente esercizio di LeetCode a tema SQL:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Write a solution to find managers with at least five direct reports.&lt;/p&gt;
&lt;p&gt;Return the result table in any order.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Guardando le tabelle fornite dall’esercizio si può notare che la tabella Employee contiene sia i dipendenti che i manager, e il campo managerId indica a quale manager ogni dipendente riporta.&lt;/p&gt;
&lt;p&gt;L’obiettivo è quindi individuare i manager che hanno almeno 5 dipendenti diretti (direct reports).&lt;/p&gt;</description></item><item><title>SQLLeetCode - 550 - Game Play Analysis IV</title><link>https://bacarotech.github.io/blog/2026/sqlleetcode---550---game-play-analysis-iv/</link><pubDate>Wed, 25 Feb 2026 14:01:14 +0000</pubDate><guid>https://bacarotech.github.io/blog/2026/sqlleetcode---550---game-play-analysis-iv/</guid><description>&lt;p&gt;Oggi vediamo il seguente esercizio di LeetCode a tema SQL:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Write a solution to report the fraction of players that logged in again on the day after the day they first logged in, rounded to 2 decimal places.&lt;/p&gt;
&lt;p&gt;In other words, you need to determine the number of players who logged in on the day immediately following their initial login, and divide it by the number of total players.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Guardando le tabelle fornite dall’esercizio si può notare che la tabella Activity registra gli accessi degli utenti nel tempo, identificando ogni giocatore tramite player_id e ogni login tramite la data event_date.&lt;/p&gt;</description></item><item><title>SQLLeetCode - 197 - Rising Temperature</title><link>https://bacarotech.github.io/blog/2026/sqlleetcode---197---rising-temperature/</link><pubDate>Wed, 25 Feb 2026 14:01:13 +0000</pubDate><guid>https://bacarotech.github.io/blog/2026/sqlleetcode---197---rising-temperature/</guid><description>&lt;p&gt;Oggi vediamo il seguente esercizio di LeetCode a tema SQL:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Write a solution to find all dates&amp;rsquo; id with higher temperatures compared to its previous dates (yesterday).&lt;/p&gt;
&lt;p&gt;Return the result table in any order.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Guardando le tabelle fornite dall’esercizio si può notare che la tabella Weather contiene le registrazioni giornaliere della temperatura, dove ogni riga è identificata da una data (recordDate) e da un id univoco.&lt;/p&gt;
&lt;p&gt;L’obiettivo è quindi confrontare la temperatura di un giorno con quella del giorno precedente, per trovare i casi in cui la temperatura è aumentata.&lt;/p&gt;</description></item><item><title>SQLLeetCode - 183 - Customers Who Never Order</title><link>https://bacarotech.github.io/blog/2026/sqlleetcode---183---customers-who-never-order/</link><pubDate>Wed, 25 Feb 2026 14:01:12 +0000</pubDate><guid>https://bacarotech.github.io/blog/2026/sqlleetcode---183---customers-who-never-order/</guid><description>&lt;p&gt;Oggi vediamo il seguente esercizio di LeetCode a tema SQL:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Write a solution to find all customers who never order anything.&lt;/p&gt;
&lt;p&gt;WReturn the result table in any order.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Guardando le tabelle fornite dall’esercizio si può notare che la tabella Customers contiene tutti i clienti, mentre la tabella Orders tiene traccia degli ordini effettuati e collega ogni ordine a un cliente tramite il campo customerId.&lt;/p&gt;
&lt;p&gt;Di conseguenza, per trovare i clienti che non hanno mai effettuato ordini, è sufficiente selezionare quelli il cui id non compare tra i customerId presenti nella tabella Orders.&lt;/p&gt;</description></item><item><title>SQLLeetCode - 181 - Employees Earning More Than Their Managers</title><link>https://bacarotech.github.io/blog/2026/sqlleetcode---181---employees-earning-more-than-their-managers/</link><pubDate>Wed, 25 Feb 2026 14:01:11 +0000</pubDate><guid>https://bacarotech.github.io/blog/2026/sqlleetcode---181---employees-earning-more-than-their-managers/</guid><description>&lt;p&gt;Oggi vediamo il seguente esercizio di LeetCode a tema SQL:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Write a solution to find the employees who earn more than their managers.&lt;/p&gt;
&lt;p&gt;Return the result table in any order.W&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Guardando le tabelle fornite dall’esercizio si può notare che la tabella Employee contiene sia le informazioni dei dipendenti che dei manager, distinguendoli tramite il campo managerId, che rappresenta un riferimento all’id di un altro dipendente. Inoltre, non tutti i dipendenti hanno un manager (ad esempio il CEO), quindi in alcuni casi managerId può essere NULL.&lt;/p&gt;</description></item><item><title>SQLLeetCode - 175 - Combine Two Tables</title><link>https://bacarotech.github.io/blog/2026/sqlleetcode---175---combine-two-tables/</link><pubDate>Wed, 25 Feb 2026 14:01:10 +0000</pubDate><guid>https://bacarotech.github.io/blog/2026/sqlleetcode---175---combine-two-tables/</guid><description>&lt;p&gt;Oggi vediamo il seguente esercizio di LeetCode a tema SQL:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Write a solution to report the first name, last name, city, and state of each person in the Person table. If the address of a personId is not present in the Address table, report null instead.&lt;/p&gt;
&lt;p&gt;Return the result table in any order.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Guardando le tabelle fornite dall’esercizio si può notare che la tabella Person contiene le informazioni anagrafiche (firstName, lastName) identificate da personId, mentre la tabella Address contiene città e stato associati allo stesso personId. Tuttavia, non è garantito che ogni persona abbia un indirizzo corrispondente nella tabella Address.&lt;/p&gt;</description></item></channel></rss>