Sort By Column numbers

You can use column numbers to indicate sort columns in the ORDER BY clause. This is especially helpful when sorting on calculated columns. Eg: Select account, ((curyear – prevyear) * 0.5) from saleshist order by 2, 1

Common table Expression(CTE)

Common table expressions (CTEs) allow you to break down complex SQL logic into smaller pieces.Common table expressions (CTEs) are simply defined using the WITH keyword. They allow for logic to be coded in a single place and simplify coding and maintainability. CTE is like a temporary view. CTE Syntax: A CTE must be part of a SELECT statement. […]

Update records from a table which exists in the other Table

Update Table1  A Set  Field1 = ‘Value’ Where exists(Select * from Table2 B where A.ID = B.ID)