Skip to content
Advertisement

Tag: postgresql

Add the last appearance to table

I have two tables (for example) 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 table1 ( purchases ): table2 ( type ): I want my query to return a table like this: where [the last place] is the last store where client bought

Update returning * and select result as rows

I want to run a few updates in a single query returning *, and select the output as rows. I currently have That does what I’m looking for but feels like it could be improved. I almost got it working like this but it displays as a single row not two separate rows Answer I think you simply want union

User Permissions error for reading from view in postgres

I am using postgres and have a new read-only user that has read permissions on all tables in a base schema. I was trying to SELECT some data from a particular view from base schema and was able to see the values from the view. To test the data count I had to make some changes in the view definition

Fill in Missing Values in Query

Say we have this dataset: Two students are enrolled in two different courses and attendance is taken for each student. I am interested in finding the attendance_dates for the students for which either one of them or both of them missed the respective subject. For the subject and the attendance_dates the students did not show up return NULL. For example:

postgreSQL LEFT and UPPER interaction

Question: Write a query that returns the name, address, state, and zipcode from all purchases. For the names, return only the first 5 characters, and display them in all uppercase letters, sorted in alphabetical order. Code so far: I’m at a loss of where and how to use UPPER to capitalize all the characters in the first column that is

Advertisement