It’s well documented on StackOverflow how to find the whole data for the row with some max value in a column per some group identifier (SQL select only rows with max value on a column). But that given …
Tag: greatest-n-per-group
Laravel query Builder Select from subquery
I’m trying to convert a sql query to a Laravel Query builder, but i find hard understand which is the best way for FORM SUBQUERY in Laravel, because if i’m not wrong, is not something that you can normally do whit query builder, but you should implement in raw. is this right? and how should translate this? I could translate
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
How to display the total count of the last row by filestatus?
I have to display the total count of the last row by filestatus. tbl_bankdata tbl_fileStatus I have two tables tbl_bankdata and tbl_fileStatus. I am sending bank_id in the tbl_fileStatus as a f_bank_id. Now I have to show the last f_bankid count. For example, I have to fetch the count where f_filestatus=1. so my output will be 0. Why 0 because
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 can I select the max for a maths operation and also other elements without the max displaying all results
I am trying to find the maximum value of something, while also selecting other attributes at the same time. When i do the max statement on its own, it works as intended, but when I select another …
How to exclude rows with similar columns?
There is a table: | date | action | issue_id | | 2020-12-14 | close | 1 | | 2020-12-15 | close | 1 | | 2020-12-16 | close | 1 | | 2020-12-14 | close | 2 | …
ms access, need to get all rows with a distinct column
I have a table called “parts” which stores information on electrical connectors including contacts, backshells etc. all parts that are part of an assembly have a value in a column called &…
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