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. grouped

grouped

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

    hi i want to make an select statment that contains some data, that is SELECT Name,ID, Sname,Schools from student imagine that this table have one student have the same ID and same name but i need the last one how can do that while there are no Primary keys . can i use grouped by Name alone or i should make a grouped by name,ID,.. Amarni

    C 1 Reply Last reply
    0
    • A Amarni

      hi i want to make an select statment that contains some data, that is SELECT Name,ID, Sname,Schools from student imagine that this table have one student have the same ID and same name but i need the last one how can do that while there are no Primary keys . can i use grouped by Name alone or i should make a grouped by name,ID,.. Amarni

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      Amarni wrote:

      imagine that this table have one student have the same ID and same name but ... there are no Primary keys

      So what is ID if not the primary key?

      Amarni wrote:

      i need the last one

      What do you mean by "the last one"? Databases contain sets of data there is no implied order of anything in the database. If you want to make something ordered then it has to be ordered on a column or columns. Which column defines the order?

      Amarni wrote:

      can i use grouped by Name alone or i should make a grouped by name,ID,..

      GROUP BY will allow you to aggregate the other columns based on the column or columns you are GROUPing BY. That means you will no longer be able to access ID, Sname, Schools other than through an aggregation function such as MIN(), MAX(), SUM(), AVG() etc.


      "On two occasions, I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able to rightly apprehend the kind of confusion of ideas that could provoke such a question." --Charles Babbage (1791-1871) My: Website | Blog

      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