Skip to content

Postgres how to return values in between Min column and Max column

totally new in learning postgres/SQL I have a table called error_table that looks like this: but I am having a hard time generating a query on how to do this dynamically when my input number is 160, I would like to return the error_percent value 4.6 because 160 sits between the min column 100 and max column 2…

Select statement using Chinese characters

i have a table store chinese address and english address i need to select address for compare which address do not same. when i select english address can compare which one different but chinese address cannot. anybody advise? thanks For Example: i want to output Answer Ok, you can use left join like below sa…

Populate DTO using query with JOIN

I have this main Product table: Additional table for storing categories that should be returned as List: Additional table for storing Payment Methods that should be returned as List: I want to return a result like this: I tried this: What is the proper way to populate this DTO? Answer If, as indicated in your…

Join many to many tables optionally

I have below tables User Intrest Hobby User_Intrest User_Hobby Now to find user ids who have both interests Eating and Sleeping I have written Output Same as above I also can find user ids with hobbies Smoking, Hiking, Browsing as below Output Now I want to mix these two optionally in a way that if only inter…

Get all values from intermediate table

I have a mySQL three-table many-to-many setup with link table, simplified here: categories category_id category_name categories2entries category_id, entry_id entries entry_id entry_text …

I am missing an alias for a derived table

I know, this question has been asked very often but I know my error, I know how I could fix it, but I can´t find the point where the error is. In my opinion, all the subqueries have different and …

A self join query

Given this relational schema people (pid, name, gender, age, email, city, state) books (ISBN, title, edition, publisher, year, rating) write (pid, ISBN) pid is a foreign key and refers to people (pid), ISBN is a foreign key and refers to books (ISBN) I need to write a SQL query to find the authors who either …

Update field with values from a select query/subquery in SQL

Hello I need to select a specific string form a field one table and then populate another field in a different table in the same SQL database. I am extracting the date from a field. The characters are between two underscores. I was able to create the Select statement correctly using guidance from a previous p…