DataSource Controls :: Pivot In Sql Server
Feb 26, 2010I want this result
Id
Name
Service [code].....
I want this result
Id
Name
Service [code].....
i have a table for customer forecast which contains customer, week number and quantit as columns. now i need to write query and list the week as column for each customer and each cell should have a quantity. how to write query for this using pivot logic. i dont want to use cursor.
View 3 RepliesIs it possible to get a Activity, year, monthly pivot from a table for a clientID? And I need to show it in a control (grid or ?)
My table has tblActivities (ActivityID, ActivityDate, ClientID)
And I have a lookup tblLookupActivities (ActID, Activity)
I need something that looks like:
Activity | Year | Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Nov|Dec|
CPR | 2007 | 1 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 3 |
Jump| 2008 | 2 | 1 | 1 | 1 | 0 | 2 | 1 | 1 | 0 | 0 | 0 | 1 | 3 |
I have a table that could look like the left table in the following picture, but i want to present it as the right table in the picture. http://pici.se/549963/?size=fullsize
So i've found out that i could use pivots to do this, but am having some trouble getting it to work, so if you know how to do this.
I'm assuming I need to use a pivot table from what I've found so far. However, every one that I've seen has not had the date setup like I have.
I have a Gridview on my page which I need to be populated like so
Date NCMR
1/1/10-1/31/10 #
2/1/10-2/28/10 #
I want to do this for 10 months... bottom record being the current month (or last month). I would also like the Date to format to January 2010 I used the above date format because that is how it is in the table. Basically, I need to know how to create the pivot table to search the table for 1/*/10, 2/*/10, etc
I'm not even sure if I'm using the correct terminology of "Pivot". I've seen several examples of pivoting in SQL but I have not found anything like I am trying to do.Can someone tell me if it's possible to pivot columns for one row like so?:
[code]...
i have the table like
TId DG rating DGMake DGCapacity
1 1 4 DG1 1X1
1 2 5 DG2 2X2
1 3 3 DG3 3X3
i need the output like this.
TId DG1 DG2 DG3 DG1Rating DG2Rating DG3Rating DG1Make DG2Make DG3Make DG1Capacity DG2Capaciy DG3Capacity
1 1 2 3 4 5 3 DG1 DG2 DG3 1X1 2X2 3X3
I have a table with the following structure and Values:
ID | Property | Value
-----------------------------
1 | FirstName| ABC
1 | LastName| XYZ
I want to get results in the following format:
ID | FirstName | LastName
----------------------------------
1 | ABC | XYZ
Please suggest a way to get the desired result.
I got the following table:
Lane Bin1 Bin2 Bin3
1 B11 B21 B31
2 B21 B22 B23
3 B31 B32 B33
How can i change the layout to
Bin1(Lane1) Bin1(Lane2) Bin1(Lane3) Bin2(Lane1) Bin2(Lane2) Bin2(Lane3) Bin3(Lane1) Bin3(Lane2) Bin3(Lane3)
B11 B21 B31 B21 B22 B23 B31 B32 B33
I tried using pivot, but cant get it.
I tried to develop a dynamic pivot query with following code to avoid hard coding. I can got the 'Q1, Q2, Q3, Q4' dynamically and assigned to @(@quarter. But it cannot be passed to the pivot query.
[Code]....
I have three tables.
CustomProfile
UserID (pk)
DisplayName
CompanyID
Teams
TeamRecordID (Pk)
TeamID
CompanyID
EmployeesInTeams
UserID
TeamID
I want to assign employees to teams via a gridview control with a templated checkbox.
I have a dropdownlist control to select the TeamID.
I am having problems with the select statement.
The gridview needs to select employees that are not assigned to any teams as well as assigned to other teams. An employee can be assigned to many teams.
What I have been trying is:
cp.UserID, cp.DisplayName, et.TeamIntID, cp.CompanyID
I am unable to date as dynamic parameter to stored procdure with pivot.i am getting
error
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.
below is my stored procedure
[code].....
I am using following pivot query but not getting result as single row getting as 4 rows.
One more problem i am unable to pass dates as parameters to storeprocedure something like this
select [@date] .
SELECT 'Forecasted' AS HeadCount,
[8/1/2010], [8/8/2010], [8/15/2010], [8/22/2010]
FROM
(SELECT *
FROM TblEmpCount) AS SourceTable
PIVOT
(
SUM(EmpCount)
FOR StartDate IN ([8/1/2010], [8/8/2010], [8/15/2010], [8/22/2010])
) AS PivotTable;
I am getting result as 4 rows but i want result in single row like this
HeadCount 8/1/2010 8/8/2010 8/15/2010 8/222/2010
Forecasted 191 182 176 169
i have a dynamic pivot table which has a parameter passed in stored procdure
i have temp table to store columns in it to be dynamic and also a parameter
but this script make me go mad
colud you find me the error Inncorrect syntax near '+@columns+'Item_Group2 table structure is ID,Name,Group1_ID this is script
[Code]....
I need to display an Excel like Pivot table in ASP.Net web.I knew there is OWC Pivot table but it looks really ugly and not like Excel's.
Is there any control out there or we can create one of our own ?
I have a doubt and i am sending you the details below, what i want to display in Gridview.
below i am describing the sql Table Structure.
Original Table Structure.
ID               Date            TimeLogged(Hrs)       UserName
1Â Â Â Â Â Â Â Â Â Â Â Â 10/8/2012Â Â Â Â Â Â Â Â Â Â Â Â Â Â 5.50Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Bubai
2Â Â Â Â Â Â Â Â Â Â Â Â 11/8/2012Â Â Â Â Â Â Â Â Â Â Â Â Â Â 2.30Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Bubai
3Â Â Â Â Â Â Â Â Â Â Â Â 10/8/2012Â Â Â Â Â Â Â Â Â Â Â Â Â Â 3.30Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Bhanu
4Â Â Â Â Â Â Â Â Â Â Â Â 11/8/2012Â Â Â Â Â Â Â Â Â Â Â Â Â Â 7.30Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Bhanu
I want result like below. User Name should be dynamic. May be lot of users. User name will come from Database table.
i want to show details in Gridview(Front End).
Date                   Bubai              Bhanu                   Total
10/8/2012Â Â Â Â Â Â Â Â Â Â Â Â Â 5.30Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 3Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 8. 30
11/8/2012Â Â Â Â Â Â Â Â Â Â Â Â Â 2.30Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 7.30Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 10
 Total                  8                   10.30                 18.30
Â
I have a doubt and i am sending you the details below, what i want to display in Gridview. below i am describing the sql Table Structure.Original Table Structure.
ID Date TimeLogged(Hrs) UserName
1 10/8/2012 5.50 Bubai
2 11/8/2012 2.30 Bubai
3 10/8/2012 3.30 Bhanu
4 11/8/2012 7.30 Bhanu
I want result like below. User Name should be dynamic. May be lot of users. User name will come from Database table. i want to show details in Gridview(Front End).
Date Bubai Bhanu Total
10/8/2012 5.30 3 8. 30
11/8/2012 2.30 7.30 10
Total 8 10.30 18.30
I'am developing a attendance software of employees with visual studio 2005 and sql server 2005, in which i have to display the attendance in a gridview withname and date as follows,
NAME (Date)1 2 3 4 5 6 7 8 9 10 .... ... 31
RAM P A P P P A
P- Present
A- Absent
I am bringing back a matrix from using a pivot table and displaying the results in a gridview. Here is the code to my gridview
[Code]....
This works fine but I want to total each column but they are dynamic so I don't know how many columns there will be. So it will look something like below:
East Midlands
0
0
0
0
0
0
0
0
0
North East
0
0
0
0
0
0
0
0
0
North London
0
0
0
0
0
0
0
0
0
North West
0
0
0
0
0
0
0
0
0
ROI
0
0
0
0
0
0
0
0
0
Scotland & NI
0
0
0
0
0
0
0
0
0
South East
1
1
0
0
0
0
0
0
0
South London
0
0
0
0
0
0
0
0
0
South Wales & West
0
0
0
0
0
0
0
0
0
West Midlands
0
0
0
0
0
0
0
0
0
Total
1
1
0
0
0
0
0
0
I am struggling to get the column totals in the footer. I have the code below which just brings back zero each time and if i move the Dim total as integer = 0 to the top as a global variable I get 54 in each of the total columns?
[Code]....
Need to bind repeater using PIVOT method via stored procedure.
View 1 RepliesI have one database in which student enroll no with his sem is stored . I want that if i enter stud enroll no then in dropdown list all the sem related to that stud should come. My databaseÂ
Stud enroll no     sem1      sem2       sem3      sem4
    1          July 2013   Jan 2014    July 2014   Jan 2015
    2          Feb 2013   Aug 2014    Feb 2014   Aug 2015Â
     3         July 2012   Jan 2013   July 2013   Jan 2014
How to insert data from local SQL server to remote SQL server (without using linked server) like below?
insert * into [remote server].[northwind].orders
from [local server].[northwind].orders
I have to programmatically import a table from a database "A" in Sql Server 2000 to a database "B" in another server 2005.
View 1 Repliesi am trying to create connection using OLEDB connection in my app. but i am not able to create the connection as in datasource i want to use Server.mappath, but cudn't find the right method to use it. i am trying to make connection with Access database file. following is code i have tried:
string path = Server.MapPath("~/uploadaccess/Production.mdb");
string ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("~/uploadaccess/Production.mdb")&";";
and also
OleDbConnection myConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & path&";");
and tried this
OleDbConnection myConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("~/uploadaccess/Production.mdb"));
and this is the error i am getting:
Operator '&' cannot be applied to operands of type 'string' and 'string'
I would like to display the results of my pivot stored procedure. What control will allow this?
View 2 RepliesMigrating SSIS package from SQL Server 2005 to SQL Server 2008
View 1 Replies