Jump to content

Recommended Posts

I had data like this

 

empno  ename       job              mgr   hiredate          sal     comm   deptno

7369     SMITH     CLERK        7902  1980-12-17    800     NULL     20

7499     ALLEN    SALESMAN  7698  1981-02-20   1600    300       30 

7521     WARD    SALESMAN  7698  1981-02-22    1250   500       30

7566     JONES    MANAGER   7839  1981-04-02    2975   NULL    20

 

1) Display the name and hire date of the employee who was hired first without using subquery

 

2) Display the name and hire date of the employee who was hired last without using subquery

 

 

Link to comment
https://forums.phpfreaks.com/topic/283607-display-name-and-hiredate/
Share on other sites

And what have you tried so far and/or what questions do you have? this forum is for people to get help with code they have written, not for people to do your homework for you. Unless your instructor is a moron I suspect he has recently gone over several different SQL functions recently. Go over those and give it a try.

And what have you tried so far and/or what questions do you have? this forum is for people to get help with code they have written, not for people to do your homework for you. Unless your instructor is a moron I suspect he has recently gone over several different SQL functions recently. Go over those and give it a try.

 

I had try for the date i using for max and min but when to call together with name I did not manage to make it because it will showing many name since i used the group by that part I stuck

You want a single record. GROUP BY is used to "group" records to get things such as the SUM, AVG, etc across many records. There are two specific functions you will want to use to get the records in a particular order and to select only the one you want for each query.

You want a single record. GROUP BY is used to "group" records to get things such as the SUM, AVG, etc across many records. There are two specific functions you will want to use to get the records in a particular order and to select only the one you want for each query.

 

ok let said I had called the min hiredate for the first hired how can i call that person only ?

because if i did like min hiredate and min ename it will not give the first hired date person

ok let said I had called the min hiredate for the first hired how can i call that person only ?

because if i did like min hiredate and min ename it will not give the first hired date person

 

MIN() is another GROUP BY function. This is not a problem to be resolved with grouping. See Barand's response above. He decided to throw you a bone.

Not quite. The ORDER BY will ensure you are getting the records in order so the newest is first or the oldest is first (based on whether you sort in ascending or descending). But, to get the first record you want to use LIMIT

 

 

  SELECT HIREDATE
  FROM EMP
  ORDER BY HIREDATE ASC <-- or "DESC"
  LIMIT 1
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.