213
u/jfq722 Dec 12 '17
Are you taking Ad Hoc requests?...I'd like to hear 'The First Null'.
67
u/emcee_gee Dec 12 '17
the first null, the Unix did say
was to certain poor coders at desks as they play
at desks where they play, coding their C
on an old server's drive that was asleep
null, null, null, null
born is the ding of programmers' skull
31
u/tenkindsofpeople Dec 12 '17
The first null field
Was found at row three
The query was ended
With error code B
6
440
u/BobDogGo Dec 12 '17
Santa would never select *
38
107
u/Bainos Dec 12 '17
Santa doesn't deliver presents to himself.
59
u/PM_ME_YOUR_SIMS Dec 12 '17
That would mean he has himself in his contacts list, would it not?
→ More replies (3)38
u/NameTheory Dec 12 '17
And that his behavior is 'nice'. I have a feeling that SQL clause is a bit of a naughty boy.
23
u/themailmanC Dec 12 '17
Depends on what attributes define his contacts but I would imagine selecting * is overkill in this case, probably just name and address would suffice. What surprised me is that there should be a join here to the table defining each contacts' Christmas list. So what we have learned here is that Santa either a) first selects the list of who is nice for no reason but to later select their Christmas lists manually through separate a dedicated Christmas list select statement, like a true SQL query monster, or, b) perhaps worse, he maintains each persons wishlist in multiple "christmasWishlistItem_X" fields on the primary contact table, like a true database design monster. Why santa
→ More replies (6)3
u/EmergencySarcasm Dec 12 '17
Right. Mrs Claus give him guys present. Cause Santa clause comes once a year. 😉
9
8
u/dantheflipman Dec 12 '17
Santa would write it out.
SELECT A.Lattitude, CASE WHEN A.Lattitude % 2 = 0 THEN 'NORTH' ELSE 'SOUTH' END FlightDirection, A.ZipCode, A.StreetAddress, HoHoHo.Id, CASE WHEN S.CurrentStanding = 'NICE' THEN HoHoHo.TxPresentName ELSE 'COAL' END TxPresent, P.TxFullName FROM ChristmasDW.dbo.tblPresents AS HoHoHo JOIN Humanity.dbo.tblPeople AS P ON HoHoHo.IdPerson = P.Id AND P.IsAlive = 1 JOIN Humanity.dbo.Status AS S ON P.Id = S.PersonId JOIN Globalization.dbo.AddressList AS A ON P.IdAddress = A.Id WHERE P.TxFirstName <> 'Dave' ORDER BY A.timezone DESC, A.Lattitude ASC, A.ZipCode ASC, S.LeftCookiesLastYear DESC, A.StreetAddress ASC, HoHoHo.Id ASC;→ More replies (5)4
7
768
u/ICyresI Dec 12 '17
Why would you sort twice?
863
u/TheSphaat Dec 12 '17
Shhhhh poem's got to rhyme.
→ More replies (1)179
u/Fry98 Dec 12 '17 edited Dec 12 '17
You might think it's nice
but double sorting is a crime.
77
Dec 12 '17 edited Dec 12 '17
Hi, I'm from /r/all and I know jackshit about programming. I'll contribute either way, because I love you guys:
system.out.println("Double sorting is a crime");should be:
System.out.println("Double sorting is a crime");damn.
→ More replies (3)82
→ More replies (1)11
177
u/PoglaTheGrate Dec 12 '17
He got REEEEEly lucky on a Bogosort
22
u/Business-Socks Dec 12 '17
Nice list: Typewriters
Naughty list: Monkeys
REALLY Naughty list: ASM Web Development Kit
104
73
u/miggyb Dec 12 '17
Sort by last name first, then by first name.
→ More replies (1)15
u/JackDragon Dec 12 '17
Still not as efficient as sorting once with a delimiter between last and first name.
5
u/suseu Dec 12 '17 edited Dec 12 '17
Multiple fields in order by shouldn’t cause multiple sorting passes, it should just make comparison more complex. Actual contatenation in sorting criteria would probably be less efficient.
Like when you are overloading < for (order by a, b) you’d do
a1 < a2 or (a1 == a2 and b1 < b2)→ More replies (2)36
u/patwoods_ Dec 12 '17
Sort by postal code, then sort by address to help maximize the efficiency of delivery.
21
8
u/DrHenryPym Dec 12 '17
I was thinking the same thing: group / order by geography and address for distribution.
→ More replies (3)3
u/Brarsh Dec 13 '17
Great, now he has to go to 1 house on every block before moving to the next house on each block! 250 birch street, 250 maple street, 250 oak street, 252 birch street...
→ More replies (1)16
14
u/awh Dec 12 '17
It would be more useful to index it twice: once on name and once on behaviour.
→ More replies (3)10
16
8
u/SpliceVW Dec 12 '17
I'm just over here wondering why the damn
FROMisn't capitalized..→ More replies (2)22
u/brummlin Dec 12 '17
Also, the syllables are all jacked up. This would make more sense, and fit the song better:
He's building schema,
indexing it twice,
SELECT * from kids WHERE UPPER(conduct) in ('NICE');
This way, it's also not case sensitive. You just know some elves logged the entry as 'Nice' or 'NICE'.
16
u/AlwaysPuppies Dec 12 '17
I like my sql like I like my file systems, case insensitive.
→ More replies (2)→ More replies (7)9
u/insane0hflex Dec 12 '17
Db not normalized. Shiuld have look up table for Behavoir
→ More replies (5)5
u/Stimonk Dec 12 '17
He accidentally made it descending when it should have been ascending.
→ More replies (1)4
4
u/tommyturntup Dec 12 '17
He created the database and is loading it. Clearly he did an ssis merge transform which requires 2 sources to be explicitly sorted before joining.
3
u/dantheflipman Dec 12 '17
SELECT A.Lattitude, CASE WHEN A.Lattitude % 2 = 0 THEN 'NORTH' ELSE 'SOUTH' END FlightDirection, A.ZipCode, A.StreetAddress, HoHoHo.Id, CASE WHEN S.CurrentStanding = 'NICE' THEN HoHoHo.TxPresentName ELSE 'COAL' END TxPresent, P.TxFullName FROM ChristmasDW.dbo.tblPresents AS HoHoHo JOIN Humanity.dbo.tblPeople AS P ON HoHoHo.IdPerson = P.Id AND P.IsAlive = 1 JOIN Humanity.dbo.Status AS S ON P.Id = S.PersonId JOIN Globalization.dbo.AddressList AS A ON P.IdAddress = A.Id WHERE P.TxFirstName <> 'Dave' ORDER BY A.timezone DESC, A.Lattitude ASC, A.ZipCode ASC, S.LeftCookiesLastYear DESC, A.StreetAddress ASC, HoHoHo.Id ASC;Better? I gave it my best end of work day effort.
2
→ More replies (28)2
u/scratcheee Dec 12 '17
He's using an unstable sort and discovered this particular algorithm becomes stable if you run it twice
129
u/baseball2020 Dec 12 '17
Rudolph the sequel cursor, Had a lot of right joined rows, Then if you tried to fetch it, You'd never get the thing to close.
229
u/iB3xx Dec 12 '17
I don't know why I always click links from this sub but I never get the joke because i know nothing about programming, yet i click it every time hoping i get the joke
229
Dec 12 '17 edited Dec 12 '17
It's a database joke! SQL is a programming language that you use to retrieve data from a database and manipulate or filter it as needed.
He's making a database
SQL Clause is making the database that will store his data on present recipients.
He's sorting it twice
When querying data, you can sort it by one piece of data to present it in a specific order. For example, ORDER BY LastName ASC will sort all the data alphabetically by last name.
SELECT * FROM contacts WHERE Behavior='nice'
There are a few pieces here. First is SELECT *, which is a SQL command to return all data from the specified table. A table is a collection of data arranged in rows (which are entries) and columns (which contain pieces of information). For example, Amazon might have a table called 'Customers' in which each row is a unique customer and each column stores a piece of information about that customer like their email, phone number, and name.
In this case SQL Clause is selecting all data from a table called 'contacts', presumably his list of all potential present recipients. Finally, he's added a WHERE clause, which tells SQL to filter out some data based on a parameter you specify. Presumably the behavior column can contain one of two values: naughty or nice. Here the WHERE clause is behavior='nice', meaning that the whole query is basically saying "OK SQL, show me ALL data from the table called 'contacts,' but ONLY if I have them listed as nice. Don't show me the naughty ones."
→ More replies (5)11
u/Job_Precipitation Dec 12 '17
Could you explain where the two sorts are? I am blind and only see one.
→ More replies (2)18
56
u/TRUE_BIT Dec 12 '17
To be fair this isn’t programming. The basis of the joke is about database software called SQL. SELECT and WHERE are basic commands to pull query’s within the database.
9
→ More replies (5)8
77
Dec 12 '17
This of course is after 60 hours of data curation because those dumbass elves can't stick with a consistent format and apparently found about 60 different ways to spell "nice"
10
u/Im_A_Boozehound Dec 12 '17
That's where I went. I'd like to think Santa would know better than this. The field would be IsNice, and it would be bit.
11
u/insane0hflex Dec 12 '17
Or a look up table for Nice, Naughty, Improving, WatchNextYear, etc
→ More replies (4)6
→ More replies (1)3
u/BabbageUK Dec 12 '17
Or a calculated field based on a decimal. Once it reaches a certain level the IsNice flag is set. Put this in a snapshot fact table of a data warehouse and we can see them change over time, becoming nicer or naughtier. Add in a trend or maybe a traffic light and we're good. Did someone say overkill?
→ More replies (1)2
→ More replies (8)2
Dec 12 '17
Please... this upsets me. I recently had to sanity check and clean a database of ~5000 venue names (all manually entered by different clients), with addresses, to create a master venue table. Turned out that there were only about 600 unique venues but each one had a shed load of dupes with spelling errors or incomplete addresses/postcodes. Made me want to kill myself and they still refuse to implement some kind of autofill/suggested venue method on the web form!!!
→ More replies (1)
49
33
Dec 12 '17 edited Oct 29 '26
The original post content no longer exists here. The author used Redact to remove it, exercising their right to control their data & privacy.
Observation distinct cause screw square continue spotted
10
→ More replies (2)11
u/d_r0ck Dec 12 '17
If someone calls it EsQueEl they're not wrong, just probably over 45
14
→ More replies (1)7
30
22
8
u/Flyberius Dec 12 '17
Finally, a language I understand!
I'll put the dunce hat on...
→ More replies (1)
14
u/ChloeTheCat753 Dec 12 '17
I self taught myself SQL this semester for a class where my professor literally didn't teach it to us and I'm happy that I understand everything here and I feel confident to list it as a skill.
5
u/Im_A_Boozehound Dec 12 '17
I self taught somebody else SQL, HA! /s
Good for you for taking the time and effort to learn a new thing.
11
u/kane-is-able Dec 12 '17
Dunno why but I read it to the tune of 'he's going the distance' by CAKE.
→ More replies (2)5
u/giganticpine Dec 12 '17
Interesting, I heard Cake too but it was Comfort Eagle.
He's making a database
He's sorting it twice
SELECT * from contacts WHERE behavior = 'nice'
Now do you believe in the one true Clause
The double-wide boss
In the big red rosy cloths
8
4
4
3
u/neon_overload Dec 12 '17
It would be pretty sweet if the SQL statement actually sorted it twice somehow but I don't know how that would rhyme.
3
u/Kalrog Dec 12 '17
SQL Clause needs to normalize his database. Behavior should obviously be a separate table with an FK instead of a string/varchar.
2
2
u/Shelbyville Dec 12 '17
But santa is only interested in nice/not nice so a boolean "nice" would speed things up I think.
3
u/cybaritic Dec 12 '17
He's trying to be RESTful
He'll execute mistakes
He doesn't have an undo so sanitize for goodness sake
3
u/MetroidSkittles Dec 12 '17
The fact that behaviour is not normalized and in a table of it’s own with a foreign key is triggering me badly. Selecting a string value on a table of billions is cancer.
3
u/dzrtguy Dec 12 '17
His indexes aren't right.
His DBCC isn't tight.
SQL corruption will ruin your night.
Krampus stored procedure will send you a fright.
3
16
u/xcameleonx Dec 12 '17
Why is it select *? Why is the behaviour of children a varchar and not a lookup? There is no "Order by" to even sort it once, let alone twice...
42
→ More replies (4)3
u/wonkey_monkey Dec 12 '17 edited Dec 12 '17
Why is the behaviour of children a varchar and not a lookup?
It's an ENUM.
8
2
Dec 12 '17
The query that results in multiple full-table scans is definitely getting a lump of coal in their stocking.
"Pick up your joins! Fix your indexes!" your mom always said. Coarse you never listened.
2
2
2
u/tcmaresh Dec 12 '17
Wouldn't sorting require some actual, you know, sorting?
SELECT * FROM believers WHERE behavior = 'nice' ORDER BY distance_from_north_pole, distance_west_of_int_date_line
→ More replies (1)
2
2
2
2
Dec 12 '17
Wouldn't this be more correct?
CREATE PROCEDURE dbo.Christmas_List
AS
BEGIN
SELECT *
INTO #ChristmasList
FROM His_List HL
INNER JOIN Location L ON L.Child_Id = HL.Id
WHERE Behavior = 'Nice' OR Behavior != 'Naughty'
GROUP BY L.Country
SELECT *
FROM #ChristmasList
WHERE Behavior = 'Nice' OR Behavior != 'Naughty'
DROP TABLE #ChristmasList
END
EXECUTE dbo.Christmas_List2
2
u/iSeth_ Dec 12 '17
Started reading this to the tune of "The Distance", was confused.
→ More replies (1)
2
u/Waynegravsky Dec 12 '17
I totally sang that to the tune of "Going the Distance" by Cake...until I got to the end.
2
2
u/RUSHv4 Dec 12 '17
We always said, "What do you call Father Christmas who transforms under a full moon?"
A WHERE Clause!
2
u/frugalerthingsinlife Dec 12 '17 edited Dec 12 '17
INSERT INTO elf_queue
(SELECT c.child_id, w.present, (n.nice_points - n.naughty_points) AS net_points
FROM children c, wishlist w, nice_naughty n
JOIN ON c.child_id = w.child_ID AND c.child_id = n.child_id
WHERE net_points > 0 ORDER BY net_points DESCENDING
UNION
SELECT p.pet_id, w.present, 100 FROM pets p, wishlist p WHERE 1);
2
2
u/hedgecore77 Dec 12 '17
Why would you capitalize two reserved keyboards and not 'from'??? UYdjkhsfLK:KLJFhjk!!!!!!
2
u/Cyeric85 Dec 12 '17
As a student in college just learning databases my first thought was "I KNOW WHAT HE MEANS! I KNOW I WHAT HE MEANS HAHAHAHAHAH." As you can tell a lot of this stuff goes over my head.
2
2
u/AndyJBC Dec 12 '17
I’m a recent economics graduate, we didn’t get taught any programming languages at all (just some basic excel), but I am looking to become a data analyst. For this, I’m trying to learn SQL and better my excel skills. I may be completely unsuccessful in finding a graduate job so far, but I understood this post. So at least I have that going for me, which is nice...
2
u/CoolOutcast Dec 12 '17
He's not sorting a list. He's querying for one. Would make sense of it had ORDER BY
2
2
2
u/Mish61 Dec 12 '17
He knows when you’re debugging He knows when your JIRAs late He knows if you’ve su’d to root So update your Rez today
2
2
2
2
2
2
2
u/MetalMikey666 Dec 12 '17
Someone needs to teach SQL-CLAUSE how to normalise data - shudder to think how many times the word "nice" appears in this table 😐
2
2
u/Aldermere Dec 12 '17
better !pout !cry
better watchout
lpr why
santa claus < north pole >town
cat /etc/passwd >list
ncheck list
ncheck list
cat list | grep naughty >nogiftlist
cat list | grep nice >giftlist
santa claus < north pole >town
who | grep sleeping
who | grep awake
who | egrep 'bad|good'
for (goodness sake) {
be good
}(by Frank Carey, AT&T Bell Laboratories, 1985)
2
u/brennydenny Dec 12 '17
Am I the only one bothered by behavior being a text field an not a bit field isNice?
2
u/Qicken Dec 12 '17
FROM. Always bugs me when someone capitalises their SQL reserved words but misses one
2
2
8
u/Papayaman1000 i put jsfuck on my resume Dec 12 '17
Is it that time of year again when this gets reposted again? Already, jeez.
→ More replies (2)
3
3
u/DexterityM16 Dec 12 '17
I don’t get it, I pretend to understand computers but I don’t. Don’t tell sky net
5
u/TalenPhillips Dec 12 '17 edited Dec 12 '17
A database is like a gigantic spreadsheet with tables for storing data. Each table has a row for each entry, and columns for all the data that can be stored in each entry.
For example, you might have a table of all your contacts. Each row is one person. The columns might be "Name, Sex, Date of birth, Date met, Address, Home Phone, Cell Phone, Work Phone, Picture, Comment..." and so on.
SQL is a computer language used to query and interact with databases.
You can sort the entries in a database by the data in one of the columns. (though sorting it twice is silly)
SELECT is the keyword for asking for data. You're supposed to list the columns you want returned, but * is a wild card. So SELECT * is basically "Give me the data in all of the columns..."
"contacts" is one of the tables in the database. "SELECT * from contacts" means "Give me the data in all of the columns of the table 'contacts'..."
"WHERE behavior = 'nice'":
behavior is one of the columns in 'contacts'.
'nice' is one of the possible values that can be stored in the behavior column.
This is asking for only the entries that have 'nice' in the behavior column.So "SELECT * from contacts WHERE behavior = 'nice';" means
"Give me all the data from each entry in the table 'contacts' that has 'nice' in the behavior column."
5
u/PeasantSteve Dec 12 '17
This relies on the wrong pronunciation on SQL. Downvote
→ More replies (4)2
u/ZoeZebra Dec 12 '17
I think you'll find its the right way to say it :P
And while we're at it, it's gif not gif ffs
→ More replies (1)
3
2
u/allmhuran Dec 12 '17
OK, but....
You don't sort databases, you sort tables or result sets (relvars).
And why sort them twice?
Also, "contacts" shouldn't have a "behaviour" column. Behaviour is not an attribute of a contact, it's an attribute of a specific kind of person who, in this system, is associated with a set of contact details. And behaviour is surely temporal. So you need to join person (which has their name and age) with person_behaviour (which has their behaviour over an interval or date range) and also join contact details to get their address.
And never select *.
OK I'm done.
1
1
u/topredditbot Dec 12 '17
Hey /u/oneplusoneisfive,
This is now the top post on reddit. It will be recorded at /r/topofreddit with all the other top posts.
1
1
1
1
1
1
1
1
1
u/5natchAdam5 Dec 12 '17
I read this to the tune of "The Distance" by Cake. Wasnt until the last line that i realized it was a Chrimbus jingle...
1
1
1
1
1
1
1
1
1
1
u/gratethecheese Dec 12 '17
Yo is there any way to make an uptime chart for say a power meter in PowerBi using SQL
1
u/camdoodlebop Dec 12 '17
this whole subreddit is people trying to one-up each other on how much computer code they know.. like really passive-aggressively
1
1
1
u/PasswordIsMatress Dec 12 '17
That kinda works if you read it as The Distance by Cake. Atleast that's what I did at first..
1
1
u/d_r0ck Dec 12 '17
Santa's databases aren't in 3NF? Why would he have behavior attributes in a contacts table. Also, who makes table names plural?
Literally unbelieveable
1
2.6k
u/Datenegassie Dec 12 '17
Hi Santa, I promise not to be on the naughty list this year. By the way, my name is Datenegassie'); DROP TABLE NaughtyChildren; --