<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	
	>
<channel>
	<title>
	Comentarios en: SQL contra el Apocalipsis Mutante (Parte 2): Calcula antes de que te devoren	</title>
	<atom:link href="https://www.soydba.es/sql-contra-el-apocalipsis-mutante-parte-2-calcula-antes-de-que-te-devoren/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.soydba.es/sql-contra-el-apocalipsis-mutante-parte-2-calcula-antes-de-que-te-devoren/</link>
	<description>Siempre aprendiendo cosas nuevas de bases de datos</description>
	<lastBuildDate>Tue, 15 Jul 2025 23:01:32 +0000</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	
	<item>
		<title>
		Por: SQL contra el Apocalipsis Mutante (Parte 4) La resistencia responde. - SoyDBA		</title>
		<link>https://www.soydba.es/sql-contra-el-apocalipsis-mutante-parte-2-calcula-antes-de-que-te-devoren/#comment-517</link>

		<dc:creator><![CDATA[SQL contra el Apocalipsis Mutante (Parte 4) La resistencia responde. - SoyDBA]]></dc:creator>
		<pubDate>Tue, 15 Jul 2025 23:01:32 +0000</pubDate>
		<guid isPermaLink="false">https://www.soydba.es/?p=2013#comment-517</guid>

					<description><![CDATA[[&#8230;] esta entrega, volvemos sobre los 10 retos iniciales (parte 1 y parte 2) para mostrar cómo lo resolvimos. No simplemente hablamos de respuestas frías, estamos hablando [&#8230;]]]></description>
			<content:encoded><![CDATA[<p>[&#8230;] esta entrega, volvemos sobre los 10 retos iniciales (parte 1 y parte 2) para mostrar cómo lo resolvimos. No simplemente hablamos de respuestas frías, estamos hablando [&#8230;]</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		Por: Diosvely Perez Arteaga		</title>
		<link>https://www.soydba.es/sql-contra-el-apocalipsis-mutante-parte-2-calcula-antes-de-que-te-devoren/#comment-515</link>

		<dc:creator><![CDATA[Diosvely Perez Arteaga]]></dc:creator>
		<pubDate>Sun, 13 Jul 2025 23:42:09 +0000</pubDate>
		<guid isPermaLink="false">https://www.soydba.es/?p=2013#comment-515</guid>

					<description><![CDATA[Parte 2   Me encanto estos  retos los disfrute 


Ejercicio 1: Calcula la tasa de infección

SELECT RefugeID,
    Population,
    Infected,InfectionRate FROM
(SELECT 
    RefugeID,
    Population,
    Infected,
    Round(CAST((Infected * 100.0 / Population) AS DECIMAL(5,2)),2) AS InfectionRate
FROM 
    SurvivorStats) As IR
WHERE 
    InfectionRate &#062; 5
	ORDER BY 
    InfectionRate DESC;

	
Ejercicio 2: Clasifica refugios según estado crítico
    
SELECT 
    RefugeID,
    FoodRations,
    WaterLiters,
    CASE 
        WHEN FoodRations &#060; 10 OR WaterLiters &#060; 50 THEN &#039;CRITICAL&#039;
        ELSE &#039;OK&#039;
    END AS Status
FROM RefugeSupplies
ORDER BY Status,RefugeID;


Ejercicio 3: Cuenta refugios por estado

SELECT RS.Status, COUNT(*) AS RefugeCount
FROM   
(SELECT 
    CASE 
        WHEN FoodRations &#060; 10 OR WaterLiters = DATEADD(DAY, -7, GETDATE())) AS MS
GROUP BY SightingDate
ORDER BY SightingDate;


Ejercicio 5: Mutantes cerca de refugios críticos

SELECT 
    rs.RefugeID,
    ms.SightingDate,
    ms.Latitude,
    ms.Longitude
FROM RefugeSupplies rs
INNER JOIN MutantSightings ms
    ON ABS(rs.Latitude - ms.Latitude) &#060;= 0.5
    AND ABS(rs.Longitude - ms.Longitude) &#060;= 0.5
WHERE (rs.FoodRations &#060; 10 OR rs.WaterLiters = DATEADD(DAY, -3, (SELECT MAX(SightingDate) AS MaxDate
    FROM MutantSightings))
ORDER BY RefugeID, SightingDate;]]></description>
			<content:encoded><![CDATA[<p>Parte 2   Me encanto estos  retos los disfrute </p>
<p>Ejercicio 1: Calcula la tasa de infección</p>
<p>SELECT RefugeID,<br />
    Population,<br />
    Infected,InfectionRate FROM<br />
(SELECT<br />
    RefugeID,<br />
    Population,<br />
    Infected,<br />
    Round(CAST((Infected * 100.0 / Population) AS DECIMAL(5,2)),2) AS InfectionRate<br />
FROM<br />
    SurvivorStats) As IR<br />
WHERE<br />
    InfectionRate &gt; 5<br />
	ORDER BY<br />
    InfectionRate DESC;</p>
<p>Ejercicio 2: Clasifica refugios según estado crítico</p>
<p>SELECT<br />
    RefugeID,<br />
    FoodRations,<br />
    WaterLiters,<br />
    CASE<br />
        WHEN FoodRations &lt; 10 OR WaterLiters &lt; 50 THEN &#039;CRITICAL&#039;<br />
        ELSE &#039;OK&#039;<br />
    END AS Status<br />
FROM RefugeSupplies<br />
ORDER BY Status,RefugeID;</p>
<p>Ejercicio 3: Cuenta refugios por estado</p>
<p>SELECT RS.Status, COUNT(*) AS RefugeCount<br />
FROM<br />
(SELECT<br />
    CASE<br />
        WHEN FoodRations &lt; 10 OR WaterLiters = DATEADD(DAY, -7, GETDATE())) AS MS<br />
GROUP BY SightingDate<br />
ORDER BY SightingDate;</p>
<p>Ejercicio 5: Mutantes cerca de refugios críticos</p>
<p>SELECT<br />
    rs.RefugeID,<br />
    ms.SightingDate,<br />
    ms.Latitude,<br />
    ms.Longitude<br />
FROM RefugeSupplies rs<br />
INNER JOIN MutantSightings ms<br />
    ON ABS(rs.Latitude &#8211; ms.Latitude) &lt;= 0.5<br />
    AND ABS(rs.Longitude &#8211; ms.Longitude) &lt;= 0.5<br />
WHERE (rs.FoodRations &lt; 10 OR rs.WaterLiters = DATEADD(DAY, -3, (SELECT MAX(SightingDate) AS MaxDate<br />
    FROM MutantSightings))<br />
ORDER BY RefugeID, SightingDate;</p>
]]></content:encoded>
		
			</item>
	</channel>
</rss>
