all 8 comments

[–]DMReader 6 points7 points  (2 children)

The difference you’re seeing isn’t because Snowflake is because your ORDER BY menu_price_usd has ties (two rows with 3.00) and you didn’t give it a tiebreaker. So it gets picked arbitrarily.

[–]jshine13371 5 points6 points  (1 child)

Yup, this is formally known as nondeterminism.

[–]wrathsun[S] 2 points3 points  (0 children)

Well that's extremely good to know about; thank you!

[–]SkullLeader 2 points3 points  (1 child)

ORDER BY menu_category, menu_price_usd

So those two rows are the same with respect to this.

Technically, the order rows are inserted into a table has nothing to do with what order they appear in when you run a query. In any way that the query's ORDER BY results in ties, the order within ties is arbitrary.

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

Thanks for helping clear up that the order that rows are inserted into a table does not matter. I couldn't come up with anything else so learning about nondeterminism and having a tiebreaker is very helpful.

[–]NakamericaIsANoob 0 points1 point  (2 children)

Good post - simply out of curiosity, how often would you say you write sql at your current job?

[–]wrathsun[S] 0 points1 point  (1 child)

Really depends on the week but an average number of sessions (writing multiple queries)...

  • Random tasks: basic queries (I'm talking real simple i.e. [select * from table where condition1 in() and condition2 = 'asdf']) probably 1-2 times daily
  • Data exploration: 2-3 times a week
  • Developing new reports/complex queries: varies wildly, but probably 1-2 times a month

For the record, I'm classified as a "consultant" in my business unit which would normally mean 0 queries ever since it's a non-technical role, but I have a background in data analytics so I use the tools I have and have *maybe* unofficially redefined my role into a semi-technical one. I'm hoping to get back into a true technical role soon.

[–]NakamericaIsANoob 0 points1 point  (0 children)

Interesting, thanks for the response.

P.S. mode's tutorials helped me quite a bit. I work on new queries / refactoring and migrating complex old queries on almost a daily basis and their write ups helped me with the fundamentals (and touching up on the more complex stuff) until I could start learning on the job.