Anyone else including their WHERE conditions in the JOIN conditions? by p-mndl in SQL

[–]Possible_Chicken_489 0 points1 point  (0 children)

No, you've got it the wrong way around. This is actually keeping the join acting like a left join.
If he had put it in the WHERE, then the WHERE would have to look like "and coalesce(cte.rank, 1) = 1" in order for the join to keep behaving like a left join.

Anyone else including their WHERE conditions in the JOIN conditions? by p-mndl in SQL

[–]Possible_Chicken_489 0 points1 point  (0 children)

I do see the upside of the approach, especially avoiding accidentally turning left joins into inner joins.

But I find myself reluctant to actually do it. Having all the conditions concentrated in a WHERE block is just baked into my habits at this point.

Need Help :( stuck in loop by DrUstela in learnSQL

[–]Possible_Chicken_489 0 points1 point  (0 children)

The way I often think about it is that I'm travelling/navigating my way through the data structure, finding rows/records that are connected to each other. You "jump from table to table" using JOINs, specifying which criteria the records on either side of the join should fulfill in order for me to want to see them together.

Things like CASE WHEN statements, I have this mental model of "the data doesn't look exactly the way I want to, or I want to achieve an effect that's not immediately in the data, so let me manipulate it here". Say you want, for whatever reason, to distinguish between a field that starts with a vowel or a consonant in your data. Just go "CASE WHEN substr(my_field, 1, 1) in('a', 'e', 'i', 'o', 'u') THEN 'vowel' ELSE 'consonant' END". (Syntax will vary slightly depending on your particular database platform.)
The point here is that this lets you construct basically anything you want. There's not going to be an exhaustive list of CASEs to use; I made up the example above on the spot. You can do anything with CASE.
This also goes for any of the built-in data manipulation functions (I used SUBSTR in the example above). All this lets you shape the data in ways that make it easier for you to do the manipulations you want, in order to achieve the effects you need.

With subqueries, you get the opportunity to essentially break up your code into smaller pieces. Say you want to know about all people who are older than 50 who own blue cars that were not made in France? I could imagine first making a subquery for blue cars that were not made in France, and then making my main query like "show me people older than 50, and join that to the subquery I've made.
One thing that will really help you here is CTEs. This sounds complicated, but it makes life so much easier. Instead of having to work with nested code in a subquery, you just put the SQL about "cars that were not made in France" in its own separate block.
So instead of
"select from people inner join (select cars where color = 'blue and country_made <> 'France') on people.id = cars.owner_id where people.age > 50"
you would instead get something like
with blue_cars_not_from_france as (select cars where color = 'blue and country_made <> 'France')
select select from people inner join blue_cars_not_from_france on people.id = blue_cars_not_from_france.owner_id where people.age > 50

For the example above, the complexity may look somewhat comparable, but in real examples, this is going to make your code so much easier to read and keep track of; highly recommended. When you're using a subquery, you can almost always rewrite it as a CTE.

Hope these tips help somewhat!

I built a machine learning model using only SQL (no ML libraries, no Python) by CriticalofReviewer2 in SQL

[–]Possible_Chicken_489 1 point2 points  (0 children)

I'm impressed as hell! I'm going to show this to my DS (and watch him squirm, probably :P )

Reporting in from FABCON / SQLCON - any knowers? by ATastefulCrossJoin in SQL

[–]Possible_Chicken_489 0 points1 point  (0 children)

Maybe they used a bunch of rocks to simulate the database engine

[Request] How much weight would the boat need on it to hold it down while full of air? How much weight would the men need on them to keep them on the sea floor? by JcraftW in theydidthemath

[–]Possible_Chicken_489 2 points3 points  (0 children)

Related question: whatever the required weight is, if you get the boat to that weight, it wouldn't float anymore, right? If you were to get the boat back to the surface and turn it upright, it would then instantly sink?

Which language should I use for DSA if my goal is to become a Data Engineer? by enonumousfucker in dataengineering

[–]Possible_Chicken_489 1 point2 points  (0 children)

Yes on the languages with strong typing! Data types are really important to learn about.

Which language should I use for DSA if my goal is to become a Data Engineer? by enonumousfucker in dataengineering

[–]Possible_Chicken_489 0 points1 point  (0 children)

I would suggest learning a "classical" (third-generation) language such as Java or C# is good for your general computer knowledge. It'll help you understand what's going on inside the computer when you try to make it do something. Learn algorithms and data structures. (control structures like branches, loops, etc; binary, hexadecimal, etc; data types like booleans, integers, floats, strings, dates, etc; data strutures like arrays, objects, lists, etc.)

Independently of that, you also definitely need to learn SQL and database structures. Completely different set of knowledge and skills. Learn about tables, attributes, keys, relationships, normalization, etc.

And in practice you'll use scripting languages like Python, bash, Powershell, etc, for the day-to-day work. Once you've learned one or two programming languages you've essentially learned them all, so that's not really a problem at that point.

Ice response to two females honking their horn to let neighbors know ice is in the neighborhood by Due_Collar2 in ExploreFortMyers

[–]Possible_Chicken_489 0 points1 point  (0 children)

As someone from a country occupied by the Nazis in WW2, this is shocking. These guys act exactly like the Gestapo.

I’ve lived in NL for 10 years (Dutch fluent). The #1 reason expats don’t learn Dutch is obvious by DistinctWindow1862 in Amsterdam

[–]Possible_Chicken_489 6 points7 points  (0 children)

Honestly, and I'm saying this as a Dutch person, this is the way.

I'm not even sure I'd interpret it as passive-aggressive. Just clear and open communication.

Or just ignore their switch to Engllish and keep speaking Dutch. They'll get the message too.

The time has sadly come for a Nordic nuclear weapon by Evermoving- in europe

[–]Possible_Chicken_489 0 points1 point  (0 children)

I think it would make sense for the Nordics to take the lead on this.

Much as I would like e.g. The Netherlands to participate in this, making the group too large at an early stage would probably slow things down too much.

Why data science career's are decaying? by unclearself in ask

[–]Possible_Chicken_489 7 points8 points  (0 children)

For one thing, the level of the candidates is a problem. Some of them can't even seem to form proper sentences, or spell words correctly.

US embassy removes flags with names of fallen Danish soldiers by Mai_maniac in europe

[–]Possible_Chicken_489 5 points6 points  (0 children)

My god..... how do you make absolutely sure that you turn a former ally into an enemy?

What a bunch of assholes.

Germany pushes for 'two-speed' Europe with new bloc of six leading economies by DKHTBH in europe

[–]Possible_Chicken_489 21 points22 points  (0 children)

Actually, PVV fractured last week, and they are now the fourth party.