Skip to content

Postgres LEFT JOIN not returning nulls?

Not sure why this is happening, but I have this query: And the item table has 100 elements. I’m looking for the resulting rows to be grouped by user_id and have each array be 100 items long. That is, if the value is not present in the vote table, to just instead sub in a 0 in its place. Unfortunately

how to display data on 2 different date ranges

I have the following date data, which is used to display MySQL data parameters and I have the following query: The result I want is that the program will display data from date :$tgaw to date: $tgak Answer You should be using prepared statements here, and also use the MySQL functions to add one month to the u…

Amend Report to use financial years and quarters

I need to amend this existing code to group by financial year (starts 1 July) and quarters, I realize that it is the below part of the query that requires amending but I can’t get it to work The full query is Sample data Lyaout as per below but with finacial yaer ^ qtrs shown instead of months Answer Be…

How do I make dates in a sample table more recent?

I have a table with about 5,000 records in a ‘sample’ database which has really old data i.e. the ‘Date’ field in this table has records from 2003. This certainly looks ‘old’ in product demonstrations …

Delete multiple rows in MySql without CTE

I have got a database with about 7000 cars, but unfortunately, only about 1000 are unique. Can I delete all the duplicated rows? The schema looks like this: Thank you!

Solve null date with case or if statement

I am wanting to process records for dates on an everyday basis. However I have a solution that will work incrementally but I need one that will load the first date if the table is null. Here is my …