Please Help Me

Discussion in 'Programming' started by seopigeon, Nov 23, 2006.

  1. #1
    Hi all :),

    I dont know much about programing i have some questions about DBMS. please help me.

    Using aggregate functions solve these questions

    The questions is 1. Find the first and second largest salary of the employee ?
    2.Display the odd number record ?
    3.Display the even number record?

    give me the syntax.


    Thanks,
    seopigeon
     
    seopigeon, Nov 23, 2006 IP
  2. maiahost

    maiahost Guest

    Messages:
    664
    Likes Received:
    35
    Best Answers:
    0
    Trophy Points:
    0
    #2
    what database are you using ? MySQL, MSSQL, Access (just a wild guess it's the third one :) Can you post the structure ?
     
    maiahost, Nov 24, 2006 IP
  3. weknowtheworld

    weknowtheworld Guest

    Messages:
    306
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    You can do is sort the table based on the salary field and extract the top two...

    As for the others... will definitely need the structure of the tables..
     
    weknowtheworld, Nov 24, 2006 IP
  4. daboss

    daboss Guest

    Messages:
    2,249
    Likes Received:
    151
    Best Answers:
    0
    Trophy Points:
    0
    #4
    1. select * from table order by salary desc limit 2

    2. & 3. - the best way i can think of doing this is to sort the query by salary and then parse the recordset.
     
    daboss, Nov 24, 2006 IP
  5. seopigeon

    seopigeon Banned

    Messages:
    249
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    i dont know exact structure table.please give me the syntax its ok. we have to use only aggregate functions to solve these question.
     
    seopigeon, Nov 24, 2006 IP
  6. vid

    vid Peon

    Messages:
    209
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    What kind of DB are you using?
     
    vid, Nov 24, 2006 IP
  7. fatmagoo

    fatmagoo Peon

    Messages:
    62
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Then everyone is just p***ing in the wind.

    Also, your question is a bit vague - what exactly do you mean by odd and even number records?
     
    fatmagoo, Nov 24, 2006 IP
  8. Luke

    Luke Peon

    Messages:
    111
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #8
    I think he means, only display the odd numbered records, 2,4,6 etc.

    If so, prehaps you could do
    SELECT id FROM blah WHERE blah%2
    SELECT id FROM blah WHERE blah!%2 (syntax is probably wrong on that one, havent tested it)
     
    Luke, Nov 27, 2006 IP