Skip to content

Laravel using a case statement

I’m trying to retrieve all messages of a conversation and display it’s status (read or unread). With a CASE I try to read the message.read property (boolean) and process it to a string. $messages = …

SQL: View Representing Missing Ranges

Given a table of rows each representing a numerical range. CREATE TABLE ranges ( start INTEGER, end INTEGER ) How could I create a view that represents the “holes” in the ranges? (Ignoring …

Combine Queries using Union All Dynamically

I have three tables: I combined those tables using UNION ALL. My problem is, each year there is a new table to be added. One example is that Table D with corresponding record Order O1-20 and Year 2020. Instead of adding another set of UNION ALL, is there any other way to achieve the same result. I’m usi…

Conditional ROW_NUMBER() to skip nulls still counting them

I am trying to add a ROW_NUMBER column to a data set that follows the order of [Withdrawal then Fee; Withdrawal then Fee] based upon whether the column NETWORKCD is null. However, my row_number formula is still counting Nulls even though it’s not displaying the numbers, like so: I am using the following…