Skip to content
Advertisement

SQL some selections into one (or get two colums from one)

I use PostgreSql, I have two tables (for example) Let table1 will contain stores, there are 2 types ‘candy store’ and ‘dental store’.
Each row contains information about a customer’s purchase in a particular store
In result i want to get money from each type of store group by id and the last date of purchase.
Money from candy stores start sum since 2016, but money from dental stores start sum from 2018
table1:

table2 :

I want my query to return a table like this:

Advertisement

Answer

if I understand correctly , this is what you want to do :

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement