Skip to content
Advertisement

Tag: greatest-n-per-group

SQL: Choose latest uploaded data

I am seeing duplicates in my data after running my sql query, and have figured out the issue stemming to our data team not updating a table but adding a new row instead. In this instance, I need to use the largest LD_SEQ_NBR to get the latest data. Given the following table — ORDERS What do I need to add

MySQL tree structure

Hello i am trying to prepare tree structure with MySql, tables look something like this. My Question is: Is it possible to do left join and sort columns by name, but if in lang is eq to “fra” return that row with that name, otherwise return “eng” name. Pseudo code So final result will be something like this, in total

Query items from a history table

I have a “library” history table (Excel like) to see where a book was or is. id date book action client 1 2020-12-01 1 toClient 1 2 2020-12-02 1 returned 1 3 2020-12-03 1 toClient 2 4 2020-12-04 2 toClient 2 5 2020-12-05 3 toClient 1 6 2020-12-06 3 returned 1 7 2020-12-07 2 returned 2 8 2020-12-08 2 toClient

How to sort and group data in request?

I have got table. It have some duplicates in purchaseNumber. I need select from this table only newest records for processing. In other words I need to: group elements by purchaseNumber sort them by docPublishDate and select newest. if any of elements in group is have status parsing_status true (suppose it was newest from step 2) any elements SHOULD NOT

Advertisement