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. Need help with "order by", "group by"

Need help with "order by", "group by"

Scheduled Pinned Locked Moved Database
databasehelpcom
4 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.
  • L Offline
    L Offline
    lnong
    wrote on last edited by
    #1

    I need help constructing a query for my database application. Please use notepad to view the text file below for the problem's description. Thanks. http://www.nghiep.com/sqlhelp.txt[^]

    A 1 Reply Last reply
    0
    • L lnong

      I need help constructing a query for my database application. Please use notepad to view the text file below for the problem's description. Thanks. http://www.nghiep.com/sqlhelp.txt[^]

      A Offline
      A Offline
      Arjan Einbu
      wrote on last edited by
      #2

      Just a small modification (in bold) to your second query: Select e.Event_ID, e.Event_Date, p.Prod_Name from EVENT e, PRODUCT p, EVENTS_PRODUCTS eps where e.Event_ID = eps.Event_ID and eps.Prod_ID = p.Prod_ID order by **e.Event_ID** p.Prod_Name DESC, e.Event_Date DESC Then the grouping of data can be done in the code that renders the HTML. (Iterate through the results, and create a "group-seperator" only when Event_ID changes...)

      L 1 Reply Last reply
      0
      • A Arjan Einbu

        Just a small modification (in bold) to your second query: Select e.Event_ID, e.Event_Date, p.Prod_Name from EVENT e, PRODUCT p, EVENTS_PRODUCTS eps where e.Event_ID = eps.Event_ID and eps.Prod_ID = p.Prod_ID order by **e.Event_ID** p.Prod_Name DESC, e.Event_Date DESC Then the grouping of data can be done in the code that renders the HTML. (Iterate through the results, and create a "group-seperator" only when Event_ID changes...)

        L Offline
        L Offline
        lnong
        wrote on last edited by
        #3

        Thanks for trying help...but I think your example would only sort the Prod_Names WITHIN each Event_ID group. But still, at the highest level, the table is sorted by Event_ID, not Prod_Name. I do not want that. I need the table to be sort by Product names.

        A 1 Reply Last reply
        0
        • L lnong

          Thanks for trying help...but I think your example would only sort the Prod_Names WITHIN each Event_ID group. But still, at the highest level, the table is sorted by Event_ID, not Prod_Name. I do not want that. I need the table to be sort by Product names.

          A Offline
          A Offline
          Arjan Einbu
          wrote on last edited by
          #4

          Ah... So I need to actually READ your text...:-O Sorry, my fault...

          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