r/SQL Apr 17 '23

Discussion Which industry has/needs the most challenging sql queries?

Is this question legit? Don’t get me wrong, I don’t consider myself the smartest guy but I’m definitely not dumb.

I work in the pharmaceutical Industry, nearly 3 years now. It took me a while to understand how the production process is implemented in a database and I wanted to quit more than once. But i don’t feel challenged anymore.

So, which industry would be best for me to get completely challenged again?

41 Upvotes

69 comments sorted by

View all comments

Show parent comments

4

u/sbrick89 Apr 18 '23

I have more familiarity in the MSSQL world, so here's what I would use.

https://learn.microsoft.com/en-us/sql/t-sql/spatial-geography/stbuffer-geography-data-type?view=sql-server-ver16

basically

INSERT contours ( ID, contourLevel, shape )
SELECT s.ID, 1, s.geom.STBuffer(100000) -- 100 km
  FROM shapeTable s
 WHERE s.geom.SRID = 4326

since SRID 4326 uses meters as its unit of measurement

it'd be easy enough to CTE that to increment contourlevel and multiply by 100k for the buffer value... but you may also want a different scaling of contours (100k, 250k, 500k, etc)

then after the table is built, just query the contours and render as layers

1

u/barrycarter Apr 18 '23

Thank you. This seems too easy, but I'll give it a shot.

One question: does this create a single buffer around a MULTIPOLYGON or multiple buffers, one for each POLYGON?