Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. how can reporting in this Situation

how can reporting in this Situation

Scheduled Pinned Locked Moved Database
databasehelp
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    karimkpg
    wrote on last edited by
    #1

    please ignore my poor english... I Need Reporting This Table in this shape.plz help me... SQL Table ---------- City        Value   --            -- Londen     20 Tehran      12 Paris         15 Londen     12 My Needed Report ----------  Londen   Tehran   Paris    ----         ----     ----   32             12       15

    S 1 Reply Last reply
    0
    • K karimkpg

      please ignore my poor english... I Need Reporting This Table in this shape.plz help me... SQL Table ---------- City        Value   --            -- Londen     20 Tehran      12 Paris         15 Londen     12 My Needed Report ----------  Londen   Tehran   Paris    ----         ----     ----   32             12       15

      S Offline
      S Offline
      Sandeep Mewara
      wrote on last edited by
      #2

      You need to use SQL PIVOT: MSDN: Using PIVOT and UNPIVOT[^] Try:

      SELECT
      'TotalValue' AS Sum_Total_Values_By_City, [London], [Tehran], [Paris]
      FROM
      (SELECT City, Value
      FROM MyTable) AS SourceTable
      PIVOT
      (
      SUM(Value)
      FOR City IN ([London], [Tehran], [Paris])
      ) AS PivotTable

      Sandeep Mewara Microsoft ASP.NET MVP 2012 & 2013 [My Latest Article(s)]: How to extend a WPF Textbox to Custom Picker Server side Delimiters in ASP.NET

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups