Skip to content

non UNIQUE constraints

So, I got in this situation: I create a table (let say model_a), in this table I have 2 cols (let say col1 and col2). I need a constraint that satisfy this reality: It’s not UNIQUE constraint, you can duplicate the first row. The only one time this constraint active is col1 is the same but col2 is diffe…

Sql join only 1 row

I want to join the table CustomerAgreementRole with only one row from AgreementRoleGroup, based on ViewPriority. Example: CustomerAgreementRole can have three rows. I only want the joined row where ViewPriority is highest Current query: Expected result: Answer Made it working with this:

PostgreSQL UPDATE statement treats keyword as a column

sorry for the noob question, just getting started with SQL and I have a problem that I could not resolve. Basically, I created a table with “date of birth” column and chose wrong TYPE (integer), so every time I am trying to enter date of birth as “1998-01-04” it is just showing 1998. S…

Reading Excel file with SQL returns null due to empty column

I am attempting to read in an Excel File from a third party but it falls over and returns null due to empty column. The file has 50 columns, a blank column and a further 48 columns. I only want the first 50 columns. If I delete or populate the empty column in Excel it works but I need to

Query Optimization in SQL in given case

These are the given tables: Question is: Write a optimized query to find out the name of all the customerIDs who ordered coffee that originated from ‘Costa Rica’ or ‘Indonesia’. My attempt: My teacher says it can be optimized more but I don’t see any way. Please Help me out. Answer Rather than these nes…