[HN Gopher] Sampling with SQL
       ___________________________________________________________________
        
       Sampling with SQL
        
       Author : thunderbong
       Score  : 46 points
       Date   : 2024-10-20 10:58 UTC (12 hours ago)
        
 (HTM) web link (blog.moertel.com)
 (TXT) w3m dump (blog.moertel.com)
        
       | tmoertel wrote:
       | Hey! I'm tickled to see this on HN. I'm the author. If you have
       | any questions, just ask. I'll do my best to answer them here.
        
       | emmelaich wrote:
       | Is there something in the SQL standard that says functions are
       | guaranteed to executed more than once?
       | 
       | I swear that once I used something like random() and it was only
       | executed once, making it useless for the task at hand. I had to
       | use some trick to ensure it was executed for each row.
       | 
       | I may have used it in the `select` part. Dialect was Oracle's,
       | from memory.
       | 
       | related: https://xkcd.com/221/
        
         | hobs wrote:
         | It depends on the function and the SQL implementation, you can
         | see in this simulator that where rand() > rand() evaluates row
         | by row in MySQL but once in SQL Server, so its easy to get this
         | stuff messed up even if the code is "equivalent" its really
         | not.
         | 
         | https://onecompiler.com/mysql/42vq8s23b
         | https://onecompiler.com/sqlserver/42vq8tz24
        
       ___________________________________________________________________
       (page generated 2024-10-20 23:00 UTC)