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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Select Query

Select Query

Scheduled Pinned Locked Moved Database
databasehelp
4 Posts 3 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.
  • G Offline
    G Offline
    Girish481
    wrote on last edited by
    #1

    There are 2 Tables, 1.Marks 2.Ctrl Marks Table have following Data : CtrlKey M1 M2 M3 M4 M5 M6 1 10 18 00 13 12 19 2 20 21 23 24 18 AB ... Ctrl Table Have following Data : CtrlKey Rollno 1 11 1 12 1 13 1 14 1 15 1 16 2 17 2 18 2 19 2 20 2 21 2 22 ... there is a new ctrlkey on every 6 rollnos I want Output Should like this : Rollno Marks (like Foreign Key) 11 10 12 18 13 00 14 13 15 12 16 19 17 20 18 21 ... Please help me to write a single select query to get output. Girish Kumar Sharma

    J G K 3 Replies Last reply
    0
    • G Girish481

      There are 2 Tables, 1.Marks 2.Ctrl Marks Table have following Data : CtrlKey M1 M2 M3 M4 M5 M6 1 10 18 00 13 12 19 2 20 21 23 24 18 AB ... Ctrl Table Have following Data : CtrlKey Rollno 1 11 1 12 1 13 1 14 1 15 1 16 2 17 2 18 2 19 2 20 2 21 2 22 ... there is a new ctrlkey on every 6 rollnos I want Output Should like this : Rollno Marks (like Foreign Key) 11 10 12 18 13 00 14 13 15 12 16 19 17 20 18 21 ... Please help me to write a single select query to get output. Girish Kumar Sharma

      J Offline
      J Offline
      jijoaresseriljose
      wrote on last edited by
      #2

      hi, i dont understand the relation between Marks and Ctrl tables. regards Jijo

      jijo jose

      1 Reply Last reply
      0
      • G Girish481

        There are 2 Tables, 1.Marks 2.Ctrl Marks Table have following Data : CtrlKey M1 M2 M3 M4 M5 M6 1 10 18 00 13 12 19 2 20 21 23 24 18 AB ... Ctrl Table Have following Data : CtrlKey Rollno 1 11 1 12 1 13 1 14 1 15 1 16 2 17 2 18 2 19 2 20 2 21 2 22 ... there is a new ctrlkey on every 6 rollnos I want Output Should like this : Rollno Marks (like Foreign Key) 11 10 12 18 13 00 14 13 15 12 16 19 17 20 18 21 ... Please help me to write a single select query to get output. Girish Kumar Sharma

        G Offline
        G Offline
        Girish481
        wrote on last edited by
        #3

        Both the table (Marks and Ctrl) have a common field "ctrlkey" and have relation between them. Please re-think upon it and do needful as early possible.

        1 Reply Last reply
        0
        • G Girish481

          There are 2 Tables, 1.Marks 2.Ctrl Marks Table have following Data : CtrlKey M1 M2 M3 M4 M5 M6 1 10 18 00 13 12 19 2 20 21 23 24 18 AB ... Ctrl Table Have following Data : CtrlKey Rollno 1 11 1 12 1 13 1 14 1 15 1 16 2 17 2 18 2 19 2 20 2 21 2 22 ... there is a new ctrlkey on every 6 rollnos I want Output Should like this : Rollno Marks (like Foreign Key) 11 10 12 18 13 00 14 13 15 12 16 19 17 20 18 21 ... Please help me to write a single select query to get output. Girish Kumar Sharma

          K Offline
          K Offline
          Krish KP
          wrote on last edited by
          #4

          this cannot be done using a simple SELECT query. 1. Create a cursor for "Marks" table 2. create a cursor for "Ctrl" table which fetches corresponding data for hte ctrlkey fetched by outer cursor 3. in the inner look you can arrange the data as you required

          Regards KP

          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