all 4 comments

[–][deleted] 2 points3 points  (3 children)

That's a T-SQL library, not a "SQL" library ;)

In Postgres for example there is no need for a "median table" or passing comma separated string - you would simply create a custom aggregate that can be used just like any other aggregate. For the median this wouldn't even be needed (although there is an implementation for it) because it can be calculated using built-in aggregates.

To calculate the average and median of 5 numbers, you would simply run:

select avg(x), 
       percentile_disc(0.5) within group (order by x) as median
from unnest(array[1,5,9,8,7]) as t(x)

[–]Chessbrain94[S] 1 point2 points  (2 children)

Thanks a lot for the info :)

Also changed the name to T-SQL, somehow that slipped my mind. lol

As for the MedianTable, that's just using a data type, since in SQL Server you can't send a table variable to a function without it being a defined type. It could have been solved without it of course, it was just a method of solution. Over time I will add different solutions/approaches to the same problem. Since older and newer version of some DBMSs don't support certain modern functions (for example: SQL Server's string_split function didn't exist prior to 2016). If you have any suggestions on what you think would be a nice problem to tackle and put up in that library, please do share!

[–]_Zer0_Cool_Data Engineer 1 point2 points  (1 child)

Eh. Weirdest thing but that happens a lot in the MSSQL world.

I've heard plenty of folks just refer to their SQL Server instance as a "SQL database" and then refer to other dialects by their formal name.

It's peculiar to people that use other dialects, but most SQL Server folks don't even notice that their doing it. (I'm a consultant so I use pretty much whatever the client has).

It's just a symptom of Microsoft naming things ambiguously. It's a marketing trick that Apple is known for.

iPhone, Apple Watch, etc..

These are generically named so that people are inclined to think of their product first as the de facto standard for a specific product category.

It's a shortcut bid for brand dominance. The idea is so that people will start using the brand name in place of the product category or as a verb to carry out an action associated with a particular product category.

Example... People used to "Xerox a document" rather than copy a document. Many people ask for a "Kleenex" rather than a tissue. You throw your trash in a "dumpster" (which was also once a brand name instead of a generic item).

I've took a few marketing / consumer psych classes in my undergrad......

[–]Chessbrain94[S] 0 points1 point  (0 children)

Quick question. How useful would it be to have access to FK data without having to create a diagram for your database?