Whoops, I sent the wrong dang fiddle URL: https://dbfiddle.uk/68MqShXH The one in the original email is where I made a new date/time field, which worked but I can't include that in the exported data, so I'm trying to composite the sample_date and sample_time fields to get the right ROW_NUMBER (or maybe it's more of a rank/dense rank situation).