Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3450802
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T09:05:07+00:00 2026-05-18T09:05:07+00:00

I’m trying out the pivot function in SQL Server 2005 for the first time

  • 0

I’m trying out the pivot function in SQL Server 2005 for the first time and running into a wall getting the result set I desire.

I have two tables defects and employees. I’m trying to get all the defects for employees in my employee table and I don’t care about any defects assigned to people outside those that are entered in my employee table (I am thinking to join to it, I have not tried a sub query yet but don’t think I’ll need to)

I want to get results grouped by (pivoted on) defects.severity field. The fields I want in the result set are: severity, assigned to, employee.name, fix data

Basically I want to roll up the data according to severity and show a count based on the severity levels of defects

Here are my tables:

CREATE TABLE [dbo].[Employees]
(
    [EmployeeId] [int] NOT NULL,
    [ManagerId] [int] NULL,
    [NTID] [nvarchar](50) NOT NULL,
    [FirstName] [nvarchar](50) NOT NULL,
    [LastName] [nvarchar](50) NOT NULL,
    [FullName] [nvarchar](100) NOT NULL,
    [ReportingGroup] [nchar](10) NOT NULL,
    [Added] [datetime] NOT NULL,
    [LastUpdate] [datetime] NOT NULL,
    [UpdateBy] [nvarchar](50) NOT NULL
)

CREATE TABLE [dbo].[defects]
(
    [Defect ID] [float] NULL,
    [SubSystem] [nvarchar](255) NULL,
    [Status] [nvarchar](255) NULL,
    [Severity] [nvarchar](255) NULL,
    [FixDate] [nvarchar](255) NULL,
    [Assigned To] [nvarchar](255) NULL,
    [Summary] [nvarchar](255) NULL,
    [Product List] [nvarchar](255) NULL,
    [Development Type] [nvarchar](255) NULL,
    [Defect Category] [nvarchar](255) NULL,
    [Defect Cause] [nvarchar](255) NULL,
    [Est Ready for Retest] [nvarchar](255) NULL,
    [Fix Stage] [nvarchar](255) NULL,
    [Planned Fix in Deployment Event] [nvarchar](255) NULL,
    [Planned Fix in Event Mgmt Group] [nvarchar](255) NULL,
    [Est Fixed Date] [nvarchar](255) NULL,
    [Other Owner] [nvarchar](255) NULL
)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T09:05:07+00:00Added an answer on May 18, 2026 at 9:05 am

    i got it with this SQL:

    select [Assigned To], [1-Urgent],[2-High],[3-Medium],[4-Low]
    from (select [assigned to],[Business Severity] from defects where [assigned to] is not null) D
    pivot
    (count([Business Severity]) for [Business Severity] in ([1-Urgent],[2-High],[3-Medium],[4-Low])) V
    

    thanks all

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.