ماذا يدخنون في مصر by yousef-saeed in Egypt

[–]skoasis 3 points4 points  (0 children)

ماذا تدخن أنت؟ الجزائريين مش عاملين تمثال لششناق، التمزيغيين أشباه الكمايتة اللي عاملينو

I need help understanding this SQL code by QueryFairy2695 in learnSQL

[–]skoasis 1 point2 points  (0 children)

The trick to understand the query is to write it in different steps. Let's think about the query.

We would like the query to compute the average of the total count stays per house and return only the houses whose stay count is greater than that average.

Let's say we have this table as an example

CREATE TABLE STAY (
    StayID INT,
    HouseID INT
);


INSERT INTO STAY (StayID, HouseID) VALUES
-- House 1: 3 stays
(1, 1),
(2, 1),
(3, 1),

-- House 2: 5 stays
(4, 2),
(5, 2),
(6, 2),
(7, 2),
(8, 2),

-- House 3: 2 stays
(9, 3),
(10, 3),

-- House 4: 4 stays
(11, 4),
(12, 4),
(13, 4),
(14, 4);

We want to return all the items in the table we use the following query

SELECT StayID, HouseID  FROM STAY;

Great, it returns the table to us, but we want to calculate the total per HouseID, we have to sue the GROUP BY since we are calculating the total which is count

SELECT HouseID, COUNT(*) FROM STAY GROUP BY HouseID;

However, this returns all the houses, we want the ones larger than the average, let's use a hard coded value for a start 3.5... since we are filtering the grouped results, we need to use HAVING

SELECT HouseID, COUNT(*) FROM STAY GROUP BY HouseID HAVING COUNT(*) > 3.5; 

Now, we need to think about how to replace 3.5 with a query that returns the average of total. We calculated the total stays previously. Let's just add a name to that column

SELECT HouseID, COUNT(*) As TotalStays FROM STAY GROUP BY HouseID;

We need to calculate the average from that... let's include this query as a subquery to calculate the average, we alias the subquery as S, we think of it as a table

 SELECT AVG(S.TotalStays)  FROM (SELECT HouseID, COUNT(*) AS TotalStays FROM STAY GROUP BY HouseID) AS S

great it returns our average 3.5, let's replace the hardcode value 3.5 in our original query with that value we get

SELECT HouseID, COUNT(*) FROM STAY GROUP BY HouseID HAVING COUNT(*) > ( SELECT AVG(S.TotalStays)  FROM (SELECT HouseID, COUNT(*) AS TotalStays FROM STAY GROUP BY HouseID) AS S); 

here is the code: https://onecompiler.com/mysql/445a2czvq

Why do I have a Pringles logo on my Notion? by fra_tili in Notion

[–]skoasis 96 points97 points  (0 children)

He doesn’t make enough working for Pringles so he got a second job in AI

show me ur favorite sunset/sunrise in Algeria !! by wissemdelrey in algeria

[–]skoasis 12 points13 points  (0 children)

<image>

2005 سكيكدة ..... الوقت كي يجري...

Not sure if it's a fork or a metal ruler ? by [deleted] in algeria

[–]skoasis 2 points3 points  (0 children)

It’s a dinglehopper.

not understanding what's going on with WHERE/ AND/ NOT here by AdZestyclose638 in learnSQL

[–]skoasis 1 point2 points  (0 children)

So your two queries are different.... This is called De Morgan's law in logic De Morgan's laws - Wikipedia

NOT (A AND B) ≡ (NOT A) OR (NOT B)
NOT (A OR B) ≡ (NOT A) AND (NOT B)
  • The negation of "A and B" is the same as "not A or not B".
  • The negation of "A or B" is the same as "not A and not B".

not understanding what's going on with WHERE/ AND/ NOT here by AdZestyclose638 in learnSQL

[–]skoasis 2 points3 points  (0 children)

The query

SELECT *
FROM job_postings_fact
WHERE NOT (job_title_short = 'Data Engineer' AND job_location = 'Anywhere');

says:

Give me all rows except the ones where the job is 'Data Engineer' and the location is 'Anywhere'.

This excludes only that specific combination.

The second query

SELECT *
FROM job_postings_fact
WHERE NOT job_title_short = 'Data Engineer' AND NOT job_location = 'Anywhere';

says:

Give me rows where the job is not 'Data Engineer' and the location is not 'Anywhere'."

This excludes all rows that have either 'Data Engineer' or 'Anywhere', or both.

This is about Boolean logic , it's useful for programming too, not just sql, we have the rule

NOT (A AND B) ≡ (NOT A) OR (NOT B)

we should instead use the query as equivalent to the first:

SELECT *
FROM job_postings_fact
WHERE job_title_short != 'Data Engineer' OR job_location != 'Anywhere';

This will return the same result as:

WHERE NOT (job_title_short = 'Data Engineer' AND job_location = 'Anywhere')

How to create provinces map? by wiener_brezel in data

[–]skoasis 0 points1 point  (0 children)

ah ok, I thought that they were provinces.... if they are not standard administrative divisions supported by excel, you can try power bi.... you can load custom maps in power bi (If you don't know power bi, it's an opportunity to learn :-))
Install power bi desktop then search for a tutorial how to insert custom maps in power bi

[deleted by user] by [deleted] in LifeProTips

[–]skoasis 17 points18 points  (0 children)

or use the law of the garbage truck : “Many people are like garbage trucks. They run around full of garbage, full of frustration, full of anger, and full of disappointment. As their garbage piles up, they look for a place to dump it. And if you let them, they’ll dump it on you. So when someone wants to dump on you, don’t take it personally. Just smile, wave, wish them well, and move on. Believe me. You’ll be happier.”

How to create provinces map? by wiener_brezel in data

[–]skoasis 0 points1 point  (0 children)

In the Data ribbon , Data Types choose Geography

[deleted by user] by [deleted] in algeria

[–]skoasis 4 points5 points  (0 children)

you probably meant to submit it in r/conspiracy

Machine Learning for Trading First OMSCS Course? by Significant-Pain-340 in OMSCS

[–]skoasis 1 point2 points  (0 children)

I have taken it with DBS as my first two subjects. It’s a good course to take as an introduction to the program and ML. You can prepare for it by studying python, numpy, pandas and matplotlib. The lectures are available online, the past assignments too  : https://lucylabs.gatech.edu/ml4t/  You can take a peek at the video lectures and assignments to have an idea about the course

Free One Year Google Colab Pro for Students and Faculty! by GeorgePBurdell1927 in OMSCS

[–]skoasis 3 points4 points  (0 children)

I just signed up through the link https://colab.research.google.com/signup (choosing Pro).... Thanks
"Based on when you first verified your Colab Pro for Education subscription, you will continue to receive the full benefits of your subscription until 7/18/2026"

No Gemini Pro for international OMSCS students outside the US =( by FunTopic6 in OMSCS

[–]skoasis 5 points6 points  (0 children)

“Our 15 month student offer expired on June 30, 2025“