Need SQL query

5 pts.
Tags:
SQL development
SQL Query
SQL tables
Hi, I have a emp table in which I have 7 columns and hiredate is one of the columns. I need to query for the hiredate which has maximum number of employees joined the company on a particular date?

Answer Wiki

Thanks. We'll let you know when a new response is added.

I woud sujest this .. This gives you the result wanted in less time. query optimized and tested.

with a.temp (j_date,cnt) as (
select join_date,count(*) as c1 from a.emp_table group by join_date
)
select j_date from a.temp where cnt= (select max(cnt) from a.temp)

concepts used … GROUP BY , Temporary table

1. The query <b>select join_date,count(*) as c1 from a.emp_table group by join_date </b> gives u ..

join date , Count of employees joined for the date
2. Thse records are taken as a temp table.

<b> select j_date from a.temp where cnt= (select max(cnt) from a.temp)</b> -> give the date with max count of joining..

Simple and the optimal query which can give u the best result
;-)

check if any more query issues … http://c1deal.blog.co.in/

Regards,
Krishna ,DBA

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following