Skip to content

Replace subquery with join for the same table

Can the expected result in this case be accomplished without a subquery ? Maybe using a join ? We have a name say ‘jose’, Expected result is all rows which has same color as jose. Query should run in both MS-SQL and ORACLE. http://sqlfiddle.com/#!18/5f7e3/2 Answer You can get this result with a JO…

Are indexes on columns with always a different value worth it?

Does creating an index on a column that will always have a different value in each record (like a unique column) improves performances on SELECTs? I understand that having an index on a column named ie. status which can have 3 values (such as PENDING, DONE, FAILED) and searching only FAILED in 1kk records wil…

SQL – Select using attributes from two tables

I am having an issue in extracting data using data of two tables in SQL. This returns A, B, C, D where E in T2 is not ZZZ. However, when I add another where clause like below, it returns data where T2 is ZZZ also. This ignores “T2.E <> ‘ZZZ’” part, but “D<>0” is not i…