SQL Server Performance

Get the average date of student in class

Discussion in 'Getting Started' started by vishu1484, Sep 16, 2009.

  1. vishu1484 New Member

    Hi,
    I want AVERAGE AGE of Student in class. For that i have date of birth student table.
    Can any one please help me out in this?
    Regards,
    Vishal
  2. satya Moderator

    Is this a classroom based question/
  3. FrankKalis Moderator

    [quote user="vishu1484"]
    I want AVERAGE AGE of Student in class. For that i have date of birth student table.
    Can any one please help me out in this?
    [/quote]
    Sorry, no offense, but have you at least tried to figure it out yourself?
    http://lmgtfy.com/?q=sql average
  4. vishu1484 New Member

    Yes Classroom based ....plz solve it na
  5. atulmar New Member

    "no free lunch".
    Select avg(datediff(year, dateofbirth, getdate())) from student
    Better you take interest in solving problems, rather than searching the solution, sql server books online gives you everything you might need to get through this.
  6. Madhivanan Moderator

    Datediff may not give correct value
    Select datediff(year,'2008-12-31 23:59:59','2009-01-01')
  7. atulmar New Member

    True, and we can debate on this topic, but I would not consider this as a problem for this class room question.
  8. Madhivanan Moderator

    [quote user="atulmar"]
    True, and we can debate on this topic, but I would not consider this as a problem for this class room question.
    [/quote]
    Yes [:D]
  9. satya Moderator

    Well said Atul, it is a thin line of interest in learning and being lazy [:)]

Share This Page