Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 SQL server Cross tab

Author  Topic 

firestart
Starting Member

4 Posts

Posted - 2004-07-06 : 05:42:05
Greetings,

Is it possible to implement Transform Statement with PIVOT in SQL Server?


Any help would be appreciated.

Thanks in Advance

kselvia
Aged Yak Warrior

526 Posts

Posted - 2004-07-06 : 06:27:28
There are several ways to do this. Search this site for crosstab or someone might post a method for your data if you post some DDL and the output requirements.
Go to Top of Page

firestart
Starting Member

4 Posts

Posted - 2004-07-06 : 06:55:31
I search and found some Crosstab topic but it does not fit my requirement and it produces error when i use it. Any help would be appreciated.
Go to Top of Page

Amethystium
Aged Yak Warrior

701 Posts

Posted - 2004-07-06 : 06:57:45
Give an example of what you're trying to do. Give some sample data plus a snapshot of the data before and after the transformation.


------------->>> BREAKING NEWS!!! <<<-------------
Saddam Hussien has weapons of mass destrcution
Go to Top of Page

firestart
Starting Member

4 Posts

Posted - 2004-07-06 : 07:43:30
Here is my Old Access Queries:

TRANSFORM Round(Sum(JobTimes.StopTime - JobTimes.StartTime) * 24, 1) as Duration
SELECT Parties.ID_Parties AS ID_Parties FROM PartyCategories RIGHT JOIN (((ParParCat INNER JOIN Parties ON ParParCat.ID_Parties = Parties.ID_Parties) LEFT JOIN Jobs ON Parties.ID_Parties = Jobs.ID_Parties) LEFT JOIN JobTimes ON Jobs.ID_Jobs = JobTimes.ID_Jobs) ON PartyCategories.ID_PartyCategories = ParParCat.ID_PartyCategories WHERE (((PartyCategories.Code)='EMP') AND ((JobTimes.StartTime)> '20040626' And (JobTimes.StartTime)< '20040714') AND ((JobTimes.StopTime) Is Not Null)) GROUP BY Parties.ID_Parties, PartyCategories.Code
PIVOT Int(JobTimes.StartTime) IN ('20040626','20040627','20040628','20040629','20040630','20040701','20040702','20040703','20040704','20040705','20040706','20040707','20040708','20040709','20040710','20040711','20040712','20040713',)'


If the User select date between July 5 - July 10
Total Hours of Employee:

Here is the sample output i want

Employee Name July5 July6 July 7 .......
Employee 1 5 5 9
Employee 2 5 3 10
Employee 3 6 2 11
Employee 4 8 7 12




Go to Top of Page
   

- Advertisement -