
Convert Rows to columns using 'Pivot' in SQL Server
Apr 10, 2013 · If you are using SQL Server 2005+, then you can use the PIVOT function to transform the data from rows into columns. It sounds like you will need to use dynamic sql if the weeks are …
How do I perform an IF...THEN in an SQL SELECT?
Sep 15, 2008 · 116 You can find some nice examples in The Power of SQL CASE Statements, and I think the statement that you can use will be something like this (from 4guysfromrolla):
sql - NOT IN vs NOT EXISTS - Stack Overflow
Which of these queries is the faster? NOT EXISTS: SELECT ProductID, ProductName FROM Northwind..Products p WHERE NOT EXISTS ( SELECT 1 FROM Northwind..[Order Details] od …
SQL WITH clause example - Stack Overflow
Sep 23, 2012 · 353 The SQL WITH clause was introduced by Oracle in the Oracle 9i release 2 database. The SQL WITH clause allows you to give a sub-query block a name (a process also called …
sql - What is SELF JOIN and when would you use it? - Stack Overflow
Jun 13, 2024 · You use a self join when a table references data in itself. E.g., an Employee table may have a SupervisorID column that points to the employee that is the boss of the current employee. To …
sql - Case in Select Statement - Stack Overflow
Jan 7, 2013 · The following examples uses the CASE expression in an ORDER BY clause to determine the sort order of the rows based on a given column value. In the first example, the value in the …
CASE .. WHEN expression in Oracle SQL - Stack Overflow
CASE .. WHEN expression in Oracle SQL Asked 13 years, 2 months ago Modified 4 years, 9 months ago Viewed 967k times
Best way to do nested case statement logic in SQL Server
I'm writing an SQL Query, where a few of the columns returned need to be calculated depending on quite a lot of conditions. I'm currently using nested case statements, but its getting messy. Is th...
Real life example, when to use OUTER / CROSS APPLY in SQL
But using subqueries, common table expressions, OUTER JOIN with RANK() and OUTER APPLY all seem to perform equally. I'm guessing this means the scenario isn't applicable to APPLY. Please …
sql - Left Outer Join using + sign in Oracle 11g - Stack Overflow
This contradicts what I linked to in my answer, which is an excerpt from Oracle Database 10g SQL (Osborne ORACLE Press Series) 1st edition (February 20, 2004), stating: "In a left outer join, the …