Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options not deleted user 55582

A pivot (or crosstab) converts row data into columnar data, and vice versa for an unpivot. Not all databases support explicit PIVOT syntax but the functionality can be implemented, often using decision logic (CASE statements, etc), aggregate functions, or an extension.

1 vote
1 answer
106 views

How to improve query to include 2 critical pieces of employee data

d.PayrollDeductionMonth = i.InvoiceProcessedMonth and d.PayrollDeductionYear = i.InvoiceProcessedYear and d.PayrollDeductionYear = '2015' and d.PayrollDeductionAmount > 0) SOURCE PIVOT
Corey's user avatar
  • 35
1 vote
1 answer
261 views

Pivoting with NULL Dates

I'm attempting the pivot below: SELECT EmpID as ID, [1] as January, [2] as February, [3] as March, [4] as April, [5] as May, [6] as June, [7] as … [Invoices] where Inv_Number not in ('1035','1039') ) AS source PIVOT ( sum(EmpDeductAmt) for TMonth in ([1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11], [12]) ) AS pvtmonth ORDER BY EmpID; …
Corey's user avatar
  • 35