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. MS Access SQL: Turn rows into column

MS Access SQL: Turn rows into column

Scheduled Pinned Locked Moved Database
databasehelpdesignsysadminquestion
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
    Katvillan
    wrote on last edited by
    #1

    I’ve tried writing queries but they just don’t work. I tried joining tables, selecting the tables more than once and renaming it using AS. I’d like to know if my desired output is really possible with mere using access sql ?? I need the query to set in my datatable for the gridview control. I am thinking of creating multiple datatable and assign them to one gridview instead of writing this complex query. But if there is a sql solution for this, I will stick to sql. Please share your ideas. Thank you. I’ve been stuck with this problem, it’s like I’m trying to turn my rows into column. Here are my tables and the desired output. Database tables: TableDATA

    ID GB FREE% FS_DATE
    1 0.58 43% 8/19/13 1:00 AM
    2 2.42 52% 8/19/13 1:00 AM
    3 4.93 2% 8/19/13 1:00 AM
    4 5.12 75% 8/19/13 1:00 AM
    5 0.50 1% 8/19/13 1:00 AM
    6 0.582 430% 8/19/13 2:00 AM
    7 2.422 520% 8/19/13 2:00 AM
    8 4.932 200% 8/19/13 2:00 AM
    9 5.122 750% 8/19/13 2:00 AM
    10 0.522 100% 8/19/13 2:00 AM

    TableFS

    ID FS MountPT FS_DATE SERVER_ID
    1 /dev/1 a 8/19/13 1:00 AM HP-UX
    2 /dev/2 b 8/19/13 1:00 AM HP-UX
    3 /dev/3 c 8/19/13 1:00 AM HP-UX
    4 /dev/4 d 8/19/13 1:00 AM HP-UX
    5 /dev/5 e 8/19/13 1:00 AM HP-UX
    6 /dev/1 a 8/19/13 2:00 AM HP-UX
    7 /dev/2 b 8/19/13 2:00 AM HP-UX
    8 /dev/3 c 8/19/13 2:00 AM HP-UX
    9 /dev/4 d 8/19/13 2:00 AM HP-UX
    10 /dev/5 e 8/19/13 2:00 AM HP-UX

    Required Output:

                (8/19/13 1:00)  (8/19/13 2:00)   (8/19/13 3:00 and so on.....)
    

    FS MountPT GB FREE% GB FREE%
    /dev/1 a 0.58 43% 0.582 430%
    /dev/2 b 2.42 52% 2.422 520%
    /dev/3 c 4.93 2% 4.932 200%
    /dev/4 d 5.12 75% 5.122 750%
    /dev/5 e 0.50 1% 0.522 100%

    M 1 Reply Last reply
    0
    • K Katvillan

      I’ve tried writing queries but they just don’t work. I tried joining tables, selecting the tables more than once and renaming it using AS. I’d like to know if my desired output is really possible with mere using access sql ?? I need the query to set in my datatable for the gridview control. I am thinking of creating multiple datatable and assign them to one gridview instead of writing this complex query. But if there is a sql solution for this, I will stick to sql. Please share your ideas. Thank you. I’ve been stuck with this problem, it’s like I’m trying to turn my rows into column. Here are my tables and the desired output. Database tables: TableDATA

      ID GB FREE% FS_DATE
      1 0.58 43% 8/19/13 1:00 AM
      2 2.42 52% 8/19/13 1:00 AM
      3 4.93 2% 8/19/13 1:00 AM
      4 5.12 75% 8/19/13 1:00 AM
      5 0.50 1% 8/19/13 1:00 AM
      6 0.582 430% 8/19/13 2:00 AM
      7 2.422 520% 8/19/13 2:00 AM
      8 4.932 200% 8/19/13 2:00 AM
      9 5.122 750% 8/19/13 2:00 AM
      10 0.522 100% 8/19/13 2:00 AM

      TableFS

      ID FS MountPT FS_DATE SERVER_ID
      1 /dev/1 a 8/19/13 1:00 AM HP-UX
      2 /dev/2 b 8/19/13 1:00 AM HP-UX
      3 /dev/3 c 8/19/13 1:00 AM HP-UX
      4 /dev/4 d 8/19/13 1:00 AM HP-UX
      5 /dev/5 e 8/19/13 1:00 AM HP-UX
      6 /dev/1 a 8/19/13 2:00 AM HP-UX
      7 /dev/2 b 8/19/13 2:00 AM HP-UX
      8 /dev/3 c 8/19/13 2:00 AM HP-UX
      9 /dev/4 d 8/19/13 2:00 AM HP-UX
      10 /dev/5 e 8/19/13 2:00 AM HP-UX

      Required Output:

                  (8/19/13 1:00)  (8/19/13 2:00)   (8/19/13 3:00 and so on.....)
      

      FS MountPT GB FREE% GB FREE%
      /dev/1 a 0.58 43% 0.582 430%
      /dev/2 b 2.42 52% 2.422 520%
      /dev/3 c 4.93 2% 4.932 200%
      /dev/4 d 5.12 75% 5.122 750%
      /dev/5 e 0.50 1% 0.522 100%

      M Offline
      M Offline
      Mycroft Holmes
      wrote on last edited by
      #2

      This article [^]may help, it is designed to work with SQL Server, I don't know if it will work with Access. It requires 2 nested queries, fist prepare your data so you have exactly what is required (join the table) and get the column names to pivot on (Date/Times). This pivot the data on the date/time column.

      Never underestimate the power of human stupidity RAH

      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