pivot

sql query on dual

This: select * from dual connect by level <= i ...will return result as 1 2 3 ... i Can the query be modified to get result row wise? i.e 1 2 3 .....i ...

SQL Rows to Columns

I have below table structure in MS SQL AirQuoteID Name SalesValue 7 M 49.50 7 N 23.10 7 +45 233.20 7 +100 233.20 7 +250 2333.10 I want a query which can return AirQuoteID M N +45 ...

how do you pivot sql data without aggregating a column

Hello, I have the following output in a query. SKILL LEVEL SCORERANGE ----------------------------------------------------------------------------- Stunts LOW 0.0 - 4.0 Stunts MED ...

Help me write a SQL Crosstab query

I have 3 tables that look like this: tblVideo: VideoID | Video Name 1 video 1 2 video 2 3 video 3 4 video 4 tblCategory: CategoryID | CategoryName 1 category1 2 category2 3 ...

staircase behavior with pivoted data

Hail to the fellow programmers and query writers, I have this beautiful query SELECT ID, [1] AS coL1, [15] AS coL2, [2] AS coL3, [16] AS coL4, [12] AS coL5 FROM MY_TABLE PIVOT (sum(INT_VALUE) FOR FUND_CODE IN ([1],[2],[15],[16],[12])) AS p --GROUP BY ID, [1] , [15] , [2] , [16] , [12] ORDER BY ID ASC That returns me data like this:...

Grouping multiple counts with each row representing one ID

Hi, I have a table that logs activity. It has an int activity column that indicates what type of activity it was and a corresponding admin_id that indicates which admin performed the action. Each row in the table represents one action, so for example, an administrator would cancel a user's account, and a row with that admin's id and acti...

Horizontal scroll inside WP7 pivot page

Hi! I'm having problems with horizontal scrolling inside Pivot control in WP7. I have a Grid with ScrollViewer and ten or more buttons inside. Since all buttons don't fit on the screen i need to be able to horizontally scroll. But when i click and drag on buttons the whole Pivot page starts moving and eventually switches to next pivot pa...

T-Sql - Pivot Error

I have the following code in a T-Sql query, I am getting the following error message and I am not really sure what is causing the error. I am writing the Pivot statement to be dynamic b/c I do not know the columns that will be returned. Error Message: Msg 8156, Level 16, State 1, Line 9 The column 'Title - Endorsement Fee / END8' was s...

column to row in sql server ?

Table: CREATE TABLE Table1 ( col1 INT, col2 nvarchar(10), col3 INT, col4 INT ); INSERT INTO Table1 (col1, col2, col3, col4) VALUES (1, 'welcome', 3, 4); My table have different data type , col2 is nvarchar h can i do this ... result: col value --------------- col1 1 col2 welcome col3 3 col4 4 ...

How to stop the WP7 pivot control handling the Flick Gesture event in Silverlight Toolkit

I have a Pivot Control in my WP7 app that by nature responds to left and right swipes to move between the pivot items. I then want to use the Flick Gesture on a UserControl (a small UI segment on my page) for something else. My user control does handle the event but so does the Pivot control, so it navigates to the next item. I have n...

SQL SELECT Query for a Total and parts building the total

Hello! I need a SQL Server Query for the following scenario: The Tables: CREATE TABLE [dbo].[JobStatus] ( [OID] [int] IDENTITY(1, 1) NOT NULL, [Name] [varchar](100) NOT NULL, [Code] [varchar](5) NOT NULL, [PictureID] [int] NOT NULL, [LastModifiedAt] [timestamp] NOT NULL, CONSTRAINT [PK_JobStatuses]...

[WPF] Unable to click on a button or write in a textbox when using Pivot control

Hi all, trying to learn to work with the windows phone 7 pivot control, I encounter a strange behaviour. I have this xaml : <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0"> <Canvas Grid.Row="0"> <TextBox Height="78" HorizontalAlignment="Left" Margin="10...

sql pivot with no aggregate

Whilst trying to pivot a sql table I came across this post Here . By using this method I have created a query. However i have now realised that it of course aggregates the results with the MAX function. However I need the Colum to pivot but for all occurrences to be show. Code taken from above post. SELECT dy, MAX(CASE WHE...

Convert tables with "id,attribute,value" columns to "id,attribute1,attribute2,..."

Hello, I've got a table in database that looks like this: CustomerId Attribute Value ================================ 30 Name John 30 Surname Smith 30 Phone 555123456 to make some use of the data I need to make it look sth. like this: CustomerId Name Surname Phone =...

making simple self join more efficent

Hi, I have a table id|level|name level can be 1,2 or 3 what I want to get is: id|lvl1name|lvl2name|lvl3name I'm using the following query SELECT L1."name" as lvl1name, L2."name" as lvl2name, L3."name" as lvl3name, L1.id FROM table as L1 JOIN table as L2 ON L1.id = L2.id JOIN table as L3 ON L2.id = L3.id WHE...

Adding values in a table in SQL 2008

Hi all, Trying to get a basic understanding of T-SQL here in SQL Server 2008. Suppose I have a table named "Issues" with columns such as: Priority User 1 Foo 1 Foo 2 Foo 5 Foo 4 Bar 5 Bar 1 Bar 1 Fuz and I wish to display a count of the Priority for each User, along with a break...

How to make Column to Row without an aggregate funtion in sql server 2005/8?

For example, I need to change from to . I know PIVOT is for that, but it requires an aggregate function; and for my case, I donot need to aggregate only need column to row. You can use the following sample data: CREATE TABLE[StudentScores] ( [UserName] NVARCHAR(20), [Subject] NVARCHAR(30), [Score]FLOAT, ) GO INSERT INT...

Transform a parent/child table to a fixed column dimentional table

I've a relational table (id, parentId, name) which I'd like to convert to a flattened dimentional table (id, Level1, Level2, Level3, Level4) I'm ok fixing the depth at 4 deep. I've made progress with a recursive CTE and pivot, but the result set isn't right I get Id Name Level1 Level2 0 Root NULL NULL 1 NULL L1 NUL...

Shifting mysql database values from a couple of columns to rows of entries

Easier to describe by showing a simplified view of the existing data structure and the desired result... CURRENTLY... Element Response ElementType ElementNumber EntryVal.1 1234.56 EntryVal 1 EntryDes.1 'Current Value' EntryDes 1 EntryVal.2 4321.0 EntryVal 2 En...

How can i aggrategate/pivot this data?

I have a set of records that keeps track of system availability. Sample data: System_ID Event DateOfEvent 1 Down 2010-05-01 13:20:10 1 Up 2010-05-01 13:25:19 1 Down 2010-05-05 10:12:12 1 Up 2010-05-06 14:10:16 2 Down 2010-05-05 20:22:22 2 Up 2...