pivot

How to apply the DRY principle to SQL Statements that Pivot Months

I'm wondering how others handle this situation... and how to apply the Don't Repeat Yourself (DRY) principle to this situation. I find myself constantly PIVOTing or writing CASE statements in T-SQL to present Months as columns. I generally have some fields that will include (1) a date field and (2) a value field. When I present this bac...

Why is this query returning unwanted results?

Good morning, I have a problem with this query: SELECT P.txt_nome AS Pergunta, IP.nome AS Resposta, COUNT(*) AS Qtd FROM tb_resposta_formulario RF INNER JOIN formularios F ON F.id_formulario = RF.id_formulario INNER JOIN tb_pergunta P ON P.id_pergunta = RF.id_pergunta ...

OLAP Pivot table refresh is resetting filter values

OK- 3 workbooks (one combined, and two seperate for two different combined areas) are accessing a CUBE reporting database that does a daily extract from Siebel. Each workbook contains approximately 15 sheets, and about 25 pivot tables. When a refresh all is done, and the OLAP query runs, it resets ONE of the filters on almost every s...

Retrieve column names from a different table?

I have a "datadump" table that has a bunch of mixed performance-related data. Something like: MachID TestDate MachType Value1 Value2 ... 00001 01/01/09 Server 15 48 00001 01/02/09 Server 16 99 19999 01/01/09 Switch 32 4.9880 19999 01/02/09 Switch 32 5.8109 ...

Using a SELECT Statement in the WHERE IN Clause i.e. WHERE blah in (SELECT b...)

Hi, I am trying to do some complex pivot query... and I need to do a select in the IN Clause... Example of the Pivot Looking at the Example in the above link, you can see they use the employee ids explicitly in their pivot. I would like to be able to do select instead of specifying the employee ids. The only way I can think of doing...

Pivot Table Grand Total at the top

We have an Excel spreadsheet with the Grand Totals at the top using a Forumla, but this isn't on the actual Pivot Table it's just in the spreadsheet. We have a client that wants the Grand Totals at the top of the Pivot Table and doesn't want us to use Formula. Does anyone know if this is possible (even using VBA or something, just so lo...

LInQ query for creating PIVOT table

I have three tables table1, table2 and table3 Table1 Id Data 1 Data1 2 Data2 3 Data3 Table2 Id Meta data 1 Meta data1 2 Meta data2 “ " “ " “ " Table 3 Id Data ID Meta Data ID Value 1 Data1 Metadata1 Value1 2 Data1 Metadata2...

Excel pivot chart linear time-scale

I have a data set (~10000 rows) with the following form: +---------------------------+---------------+-------------+ | DateTimeCreated | Machine | ProductName | +---------------------------+---------------+-------------+ | 2009-03-03 00:00:12.217 | COMP001 | Product001 | +---------------------------+------------...

How to pivot a MySQL entity-attribute-value schema

I need to design tables which stores all the (Attributes) metadata of Files i.e., FileName, Author, Title, CreatedDate ... and Custom Metadata ( Metadata added to files by Users) Before examining the tables we can not say what and how many custom tags have been added on Files. Custom Tags i.i.e, CustUseBy, CustSendBy etc. Now To store ...

Excel Pivot

Hello, I am an excel newb, wondering if excel has built in functionality to do the following. Turn this data: Name | Activity | Option Bob | Monday Activities | Golf Bob | Tuesday Activities| Kayak Marge | Monday Activities | Spa John | Tuesday Activities| Soccer Liz | Tuesday Activities| Spa Into: Name | Monday A...

Pivot against a SQL stored procedure (or LINQ)

I am trying to create a Stored procedure (or query expression) that Pivots on a grouping ID. After looking at the examples here and elsewhere I have failed to get my pivot statements to work in a stored procedure, and I am looking my help. Also, if this could be done with LINQ on a LIST that would be a solution for me also. theID ...

Using Pivot in SQL

For example I have a table IPPARSED 127 0 0 1 now I need to pivot the table so it can come like this 1       2   3   4 127   0   0   1 Can you help me how? ...

Updates on PIVOTs in SQL Server 2008

Is there a way to perform updates on a PIVOTed table in SQL Server 2008 where the changes propagate back to the source table, assuming there is no aggregation? ...

Pivot Chart Creation Using Access 2007 VBA

OK there are absolutely no good articles on the internet that I can find that explain or have code examples on how to create a pivot chart using VBA. I need this because I need the pivot chart to show different results depending on user selection in a form. There are some for Excel but the syntax is different for Access. I know this is a...

XSLT to denormalize/pivot/flatten xml file? Part 2

(Note: I have posted a variation on my earlier question as suggested) Given an input xml file with following structure: <widgets> <widget shape="square" material="wood" color="red" /> <widget shape="square" material="metal" color="blue" /> <widget shape="square" material="plastic" color="green" /> <widget shape="squar...

Getting a Dynamically-Generated Pivot-Table into a Temp Table

I've seen this, so I know how to create a pivot table with a dynamically generated set of fields. My problem now is that I'd like to get the results into a temporary table. I know that in order to get the result set into a temp table from an EXEC statement you need to predefine the temp table. In the case of a dynamically generated piv...

SQL Server PIVOT help.

Source table: Create Table ExamAnswers { StudentID varchar(12), QuestionID int, Answer char(1) } and this will be filled with Bob 1 a Bob 2 c ... Bob 100 b Chris 1 c Chris 2 d ... Chris 100 null etc, for about 500 students. Chris did not finish the exam, but the 100th question is stored as null, so it is guaranteed that e...

SQL Pivot for foreign key column

I have a table like so: Fiscal Year, Region, Country, Office1, Office2, Office3, Office4 Where office 1-4 are foreign keys. I would like to get output like so: Office 1: Fiscal Year, Region, Country Office 2: Fiscal Year, Region, Country Office 3: Fiscal Year, Region, Country Office 4: Fiscal Year, Region, Country Can this be done usi...

Excel pivot table question - How to get subtotals for a row area field?

I have the following situation in database: Department table holds all departments in the company. Employee table holds all employees, together with their department id and AllowedAbsenceDays field, which tells us how many days is the employee alowed to be absent in the current year. Absence table holds all absences that occur in the...

How to Pivot data from one table with SQL server 2005

Hello, I would like to create a query from a single table with the following columns. SEQNO is a unique key Name ID Amount Date JOBID SEQNO Mark 9 200 1/2/09 1001 1 Peter 3 300 1/2/09 1001 2 Steve 1 200 2/2/09 1001 3 Mark 9 200 3...