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

  • SEARCH
  • Home
  • 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 9289499
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T20:11:42+00:00 2026-06-18T20:11:42+00:00

I want to show data like pivot grid. I am right now showing data

  • 0

I want to show data like pivot grid. I am right now showing data like following. Please see following image or click on link.
http://screencast.com/t/CWeGy0vi
enter image description here

But I want above data like following:
http://screencast.com/t/ZTb2wk4cdmB
enter image description here

Any suggestion how to achieve this. Starting point. Should I use repeater?

  • 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-06-18T20:11:43+00:00Added an answer on June 18, 2026 at 8:11 pm

    Without seeing your table structure, etc. it is hard to give an exact answer. But I can suggest how you could perform this in SQL. You have some previous questions tagged with sql server so I am guessing that.

    You can do this using both an UNPIVOT and a PIVOT:

    ;with unpiv as
    (
      select activity, 
          work, 
          Location+'_'+col as col, 
          value
        from
        (
          select activity,
            work,
            cast(AssignedTasks as varchar(50)) AssignedTasks,
            cast(CompletedTasks as varchar(50)) AchievedTasks,
            Location
          from yourtable
        ) src
        unpivot
        (
          value
          for col in (AssignedTasks, AchievedTasks)
        ) unpiv
    ),
    piv as
    (
      select Activity,
        work,
        London_AssignedTasks, 
        London_AchievedTasks,
        Geneva_AssignedTasks, 
        Geneva_AchievedTasks,
        row_number() over(partition by activity order by activity, work) rn
      from unpiv
      pivot
      (
        max(value)
        for col in (London_AssignedTasks, London_AchievedTasks,
                    Geneva_AssignedTasks, Geneva_AchievedTasks)
      ) piv
    )
    select case when rn = 1 then activity else '' end activity,
      work,
      London_AssignedTasks, 
      London_AchievedTasks,
      Geneva_AssignedTasks, 
      Geneva_AchievedTasks
    from piv
    

    See SQL Fiddle with Demo.

    The result is:

    |   ACTIVITY |   WORK | LONDON_ASSIGNEDTASKS | LONDON_ACHIEVEDTASKS | GENEVA_ASSIGNEDTASKS | GENEVA_ACHIEVEDTASKS |
    -------------------------------------------------------------------------------------------------------------------
    | Activity 1 | Task 1 |                   10 |                    8 |                    1 |                    1 |
    |            | Task 2 |                   15 |                   15 |                  100 |                   25 |
    | Activity 2 | Task 1 |                    5 |                    5 |                    0 |                    0 |
    |            | Task 2 |                    0 |                    0 |                    2 |                    2 |
    | Activity 3 | Task 1 |                   10 |                   10 |                   50 |                   40 |
    

    Edit #1, If you have an unknown or dynamic number of Locations then you can use dynamic SQL to return the result:

    DECLARE @cols AS NVARCHAR(MAX),
        @query  AS NVARCHAR(MAX)
    
    select @cols = STUFF((SELECT ',' + QUOTENAME(Location+'_'+t.tasks) 
                        from yourtable
                        cross apply
                        (
                          select 'AssignedTasks' tasks
                          union all
                          select 'AchievedTasks'
                        ) t
                        group by location, tasks
                        order by location
                FOR XML PATH(''), TYPE
                ).value('.', 'NVARCHAR(MAX)') 
            ,1,1,'')
    
    set @query = ';with unpiv as
                  (
                    select activity, 
                        work, 
                        Location+''_''+col as col, 
                        value
                      from
                      (
                        select activity,
                          work,
                          cast(AssignedTasks as varchar(50)) AssignedTasks,
                          cast(CompletedTasks as varchar(50)) AchievedTasks,
                          Location
                        from yourtable
                      ) src
                      unpivot
                      (
                        value
                        for col in (AssignedTasks, AchievedTasks)
                      ) unpiv
                  ),
                  piv as
                  (
                    select Activity,
                      work,
                      row_number() over(partition by activity order by activity, work) rn,
                      '+@cols+'
                    from unpiv
                    pivot
                    (
                      max(value)
                      for col in ('+@cols+')
                    ) piv
                  )
                  select case when rn = 1 then activity else '''' end activity,
                    work,
                    '+@cols+'
                  from piv'
    
    
    execute(@query)
    

    See SQL Fiddle with Demo

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

Sidebar

Related Questions

I want to show a custom image with some data in it while clicking
i want to show some data in percent. i have a mathematics formula like:
I want to show my data in the format like below: <table> <tr> <td></td>
I want to show the data or about us to edit like stackoverflow so
In sql I want to show statistics data, so I'd like to show sums
I want to show data that returned from controller, in onComplete function: function onComplete()
In the ASP.NET MVC Razor engine I want to show three data entries in
i have created an application which show data from user current location. I want
I've got a list of data in an observableArray and I want to show
I have a table with many rows of data, and I want to show

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.