473,320 Members | 1,828 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

How to change output format from Pivot solution

45
Hi,

I am using following pivot to get the result but getting error
Expand|Select|Wrap|Line Numbers
  1. SELECT StartDate,[headCount] AS headCount 
  2. FROM 
  3. (SELECT StartDate, headCount
  4. FROM SAR_HeadCount ) ps
  5. PIVOT
  6. (
  7.   headCount
  8.   for StartDate IN
  9.   ([headCount])
  10. ) AS pvt 
When i use select * from tableName i am getting following data
Expand|Select|Wrap|Line Numbers
  1.      StartDate                            Headcount
  2.       08/01/2010                              182
  3.       08/08/2010                              176
  4.       08/15/2010                              198
  5.       08/15/2010                              192
  6.  
I want data like this
Expand|Select|Wrap|Line Numbers
  1.        08/01/2010   08/08/2010    08/15/2010   08/22/2010
  2.          182             176             198             192
  3.  
datewise headCount.
Oct 2 '10 #1
2 1686
NareshN
45
Hi All,

How to pass dynamic dates to stroed procedure with pivot.i am getting error while running belwo stored procedure

Msg 8114, Level 16, State 1, Procedure Sample, Line 3
Error converting data type nvarchar to datetime.
Msg 473, Level 16, State 1, Procedure Sample, Line 3
The incorrect value "@date1" is supplied in the PIVOT operator.


Expand|Select|Wrap|Line Numbers
  1. create procedure Sample(@date1 datetime,@date2 datetime,@date3 datetime,@date4 datetime,@CampaignID int)
  2. AS
  3. SELECT 'Forecasted' AS HeadCount,
  4. [@date1] as date1
  5. FROM
  6.  (SELECT * FROM SAR_HeadCount) AS SourceTable PIVOT
  7.   (SUM(HeadCount) FOR StartDate IN ([@date1])) 
  8. AS PivotTable;
Oct 4 '10 #2
Frinavale
9,735 Expert Mod 8TB
Please post the C# or VB.NET code that you have implemented which uses this stored procedure since that is where the error is occurring.

Also, what control are you using to display the data?

-Frinny
Oct 4 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: sportsfntc | last post by:
Hello everyone.. After much searching for the fact that in Access 2002/XP, the pivot table options (like the toolbar buttons and the add to button) are grayed out in some cases, I am happy to...
1
by: Joe Harris | last post by:
I've searched everywhere but can't find a KB article or forum message about this one... Excel Pivot Tables differentiate between +0 (zero) and -0 (negative zero)and now that I've moved over to...
0
by: (PeteCresswell) | last post by:
I'm pretty far into a solution using MS Graph - i.e. it's too late to change now... - but from what little I've been able to find, using a Pivot-Table form sounds like the latest-and-greatest way...
2
by: Carl Gilbert | last post by:
Hi I have a math kinda problem where I'm trying to split some lines when two or more lines connect two shapes. The reason I am doing this is to make it clear that there are multiple lines...
1
by: afirst | last post by:
Hello. I am working on pivot tables-I want the pivot tables to run only if a value does not equal 'Y'. Here's the code I am using: With ActiveChart.PivotLayout.PivotTable.PivotFields("IRIV") ...
9
by: PeteCresswell | last post by:
I've got something called "Reference Rates". The idea is that on a given day, we have various rates of return for various entities. e.g. Libor 3-month return, Libor 6-month return, US Treasury...
1
by: Yisehaq | last post by:
I am working on a web document to be run from CD. I included the pivot table in it but data source for pivot table doesn't work when I used a relative path. It only takes the absolute path e.g....
1
by: dhanushram | last post by:
I have 3rd party research data which is in excel pivot table form. I want to import the underlying Pivot data into Access for further analysis. A simple import in Access does not work. Tried...
0
by: retroviz | last post by:
Hello and thankyou in advance for your help :) I am developing a sales forcasting application that allows users to enter expected prices for different products by month. I have about six months...
0
by: katie Natalie | last post by:
Hi I am hoping there is a macro solution to this hence being in the VBA forum, apologies if it's incorrect placement. I have a large pivot table restricted by page, row, column and value...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.