Skip to content

How do I find the 2nd most recent order of a customer

I have the customers first order date and last order date by doing MIN and MAX on the created_at field (grouping by email), but I also need to get the customers 2nd most recent order date (the order date right before the last orderdate ) Answer Use window function ROW_NUMBER() (available in MySQL 8.0): This w…

Combine SQL Data into 1 row

I’m attempting to build code to create an SSRS report. The folder type ID 19 indicates a Member ID. If the Folder type ID includes a *1300 it indicates a provider ID that is located in that field, prior to the *1300. The issue with how I am currently doing it is that it is creating 2 rows. One where

Join three tables based on one key, putting data into same column

I have three tables that I am trying to join together to check that the proper data matches. I have table A which is a list of all accounts that a commission was paid on and what that commission amount was. I have Table B and Table C which are two tables that have commission calculations in it. The goal