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. SQL Query Problem

SQL Query Problem

Scheduled Pinned Locked Moved Database
databasehelpquestion
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.
  • R Offline
    R Offline
    rachitdamani
    wrote on last edited by
    #1

    Hi all, I need some help regarding SQL query. I have the following requirement: I have 3 tables(in bold) with columns as following: Unit UnitId ListUnit UnitId,ListId List ListId And I have the records as following in the above mentioned tables: Unit 1 2 3 ListUnit 1,1 1,3 2,1 2,2 3,2 3,1 List 1 2 3 Now I want to retrieve only top 1st (UnitId,ListId) from the group I.e. 1,2 from (1,2 1,1 1,3) group. Then 2,1 from (2,1 2,2) group. And 3,2 from (3,2 3,1) group. So how could I write SQL Query for this? Thanks, Rachit Damani.

    G 1 Reply Last reply
    0
    • R rachitdamani

      Hi all, I need some help regarding SQL query. I have the following requirement: I have 3 tables(in bold) with columns as following: Unit UnitId ListUnit UnitId,ListId List ListId And I have the records as following in the above mentioned tables: Unit 1 2 3 ListUnit 1,1 1,3 2,1 2,2 3,2 3,1 List 1 2 3 Now I want to retrieve only top 1st (UnitId,ListId) from the group I.e. 1,2 from (1,2 1,1 1,3) group. Then 2,1 from (2,1 2,2) group. And 3,2 from (3,2 3,1) group. So how could I write SQL Query for this? Thanks, Rachit Damani.

      G Offline
      G Offline
      gauthee
      wrote on last edited by
      #2

      You are saying groups, what exactly will be in a group? When you say 1,1 from 1,1;1,2;1,3 what are these values? are these a comination of unit and list tables or values from unitlist table?

      Gautham

      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