pivot

SQL - columns for different categories

I am new to SQL. I have a database with data for different exams, for example: Student Test Grade -------------------- St1 T1 A St2 T1 B St3 T1 B St1 T2 B St2 T2 B St3 T2 A St1 T3 A St2 T3 C St3 T3 B Then, I would like to print a report using the Tests (T1, T2 and T3) as columns: Student ...

Is this SQL Query possible?

Suppose I have this data: Employee Task IsCurrent -------- ---- --------- Jeff 1 Yes Jeff 2 No Jane 1 No Jane 2 Yes Jane 3 No Jane 4 No Jake 1 Yes Employees have some number of tasks, and one of them will be current. The task number indicates an ordering -- t...

Help writing SQL query..

Possible Duplicate: Need help with a SQL query that combines adjacent rows into a single row So this is how my table looks. ..and I need to write a query to get the output like this: This is not a homework question. ...

Table Conversion- Oracle

I have a table with this structure: date colname value ---------------------------- date col1name col1's value date col2name col2's value date col3name col3's value Now I need to convert it into this structure: date col1name col2name col3name ----------------------------------------------- date col1's ...

Calculate difference from previous item with LINQ

I'm trying to prepare data for a graph using LINQ. The problem that i cant solve is how to calculate the "difference to previous. the result I expect is ID= 1, Date= Now, DiffToPrev= 0; ID= 1, Date= Now+1, DiffToPrev= 3; ID= 1, Date= Now+2, DiffToPrev= 7; ID= 1, Date= Now+3, DiffToPrev= -6; etc... Can You help me create suc...

I would like to combine ROLLUP with PIVOT - is that an option?

I have been using SELECT Author, ISNULL(MAX(CASE Status WHEN 'Duplicate' THEN NumDocs END),'') AS Duplicate, ISNULL(MAX(CASE Status WHEN 'Failure' THEN NumDocs END),'') AS Failure, ISNULL(MAX(CASE Status WHEN 'Rejected' THEN NumDocs END),'') AS Rejected, ISNULL(MAX(CASE Status WHEN 'Success' THEN NumDocs END),'') AS...

Uing PIVOT/UNPIVOT to convert rows to columns...

Hi, I have been reading up on PIVOT an UNPIVOT but have not been able to get the results formatted correctly to present the data. Here is my source table: StepID | ShortDesc | Type_1 | ar1 | ar2 1 ShortDesc1 10 11.11 11.01 2 ...

sql query (potentially solvable with pivot / unpivot?)

Hi, I'm not sure how best to approach this - I think a pivot / unpivot should be used, but not sure how to make it work (as pivoting column is a non-numeric) I have the following table (based on a query I can't modify): CREATE TABLE #data (donor_id NVARCHAR(50) ,last_gift DATETIME ,[2005] NVARCHAR(50) ,numgifts05 INT ,value_05 MONEY ,...

How to Select a Particular PivotItem in Windows Phone 7 Using WP7 Panorama & Pivot Controls?

I have started using the Windows Phone 7 Panorama & Pivot Controls for a Windows Phone 7 application. In an OnNavigatedTo event, I'm trying to select which PivotItem to start the new View on. All SelectedItem and SelectedIndex seem to do is select the header. The content of the PivotItem is not shown and while the header is selected the ...

How to store TSQL query results for later display

I've never used TSQL before, but I decided I wanted to poke around in the SO data dump anyways. So this is probably a rookie question. I did try to search for an answer, but I don't know the technical term for what I'm trying to do, and search is only so good if you don't have the right keywords. My goal is to find out how many question...

T-SQL Pivot to display One Comment field per week

I've been asked to change a pivot query that currently displays a week ending date, category and hours by date for one week in a row. I've been asked to display a comment field at the end of the row and I can't figure out how to alter the query to do this. The table is structured like this Category Date Comments Hours test...

Looking for Pivot Chart capability similar to Excel's PivotChart

I am looking for a .NET pivot charting component that is similar to Excel's PivotChart. This component would be used to display data to users as part of a smart client. Users may wish to slice and dice the data in a variety of ways. Ideally, the PivotChart component would allow the user to select a variety of ways to group and aggregate ...

Pivot DataTable with Unknow number of columns

How would you go about pivoting data in a datatable where the number of columns varies from? A few columns would always be in the datatable such as ID and Name but the rest could vary. I have been struggling a lot with this and can't seem to come up with an elegant solution. Does anyone have a suggestion? ...

Sql Pivot top N rows only

I have Following structure Col1 Col2 Col3 --------------- F P R1 F P R2 F P R3 F P R4 Col3 values can be any thing Now I want in following format only top 3 Col1 Col2 Res1 Res2 Res3 ------------------------------ F P R1 R2 R3 ...

SSRS matrix pivot

I have following structure: Col1 Col2 Col3 --------------- F P R1 F P R2 F P R3 F P R4 Col3 values can be anything. Now I want, in following format, only the top 3: Col1 Col2 Res1 Res2 Res3 ------------------------------ F P R1 R2 R3 I tried it using Matrix, but I m not able to separate t...

pivot sql to create a custom DataTable ??

I am currently working on a project in C# and use MySql as database. I am currently having a problem with creating a custom DataTable I want to show in my Report. Extra Info : A test can have any no combinations of Cells & Valves for a test But for one test it uses set range of Vales and Cells are predefined before each test. Results T...

How to set a different unselected style for Pivot headers?

I'm using a Pivot control with a HeaderTemplate to set the color of the header. However, I haven't found a way to change the color of the unselected pivot items. They default to an opaque version of the header color. Does anyone know how to set the color of the unselected items? ...

Select Multiple Items in CustomPivotViewer of Silverlight

I'm thinking of CTR-Clicking each item to build up an array to add.... or even more fancy, drag select an area of items (don't think this is possible tho). I'm aware of the custom events such as ItemDoubleClicked, but is there something like ItemSingleClick, where I can check if the CTR/SHIFT key is being pressed before executing an act...

JQuery Plugin for Pivot Tables

Are there any JQuery plugins that create pivot tables? I searched and searched but didn't find anything on the net. Anyone know of any good ways to create pivot tables on the clientside? ...

SQLite3 group by using columns, not rows

What's the easiest way to fix this sqlite3 query so that wins and losses show up as columns in a single row instead of in two separate rows? http://0890db80061d7d2b33eb4606a4c301c1.conquerclub.db.94y.info/ I can think of hard ways involving subselects, but surely there's an easy/efficient/beautiful solution here? I want to avoid so...