Write a query to display the block number and number of departments in each block
Generate your own badge code here. Toggle navigation. Cancel Not a member? Sign Up Forgot Password? Let us first count the total number of records in the table with this count command.
Now we can add some condition to this SQL to count the records with different conditions. Let us find out the number of students in class Four in out table.
This article is written by plus2net. Number of Comments : I need to see them on single web page together. Rajan Arora Really simple and nice way to explain Gr8 gng Keep it Up Bruno Pls I need a syntax for count with this scenario: patients who visited their gp in the last three months.
Siddharth how to add a new row of total at the last of all the integer record. Alvin Hi there, is it possible to do this? Swetha How to find highest value in the table where no total column we need to find highest without having total column.
Subscribe to RSS
Contact us. Pls I need a syntax for count with this scenario: patients who visited their gp in the last three months. Pls i need a syntax to increase the count by 1. Hi there, is it possible to do this?
The dark mode beta is finally here. Change your preferences any time. Stack Overflow for Teams is a private, secure spot for you and your coworkers to find and share information. You're almost there. Order the result in descending order on the number of students and then take the first row:.
Learn more. Write a query to display the name of the department that has the maximum student count Ask Question. Asked 1 year ago. Active 10 months ago.
Viewed 2k times. APC k 18 18 gold badges silver badges bronze badges. Sakshi Negi Sakshi Negi 13 4 4 bronze badges. Active Oldest Votes. Robert Kock Robert Kock 5, 1 1 gold badge 9 9 silver badges 18 18 bronze badges. The queries for both the scenarios is mentioned below. Oracle SQL query for result with the department name, i.
Harsh Bhatia Harsh Bhatia 11 4 4 bronze badges. Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. The Overflow Blog. Featured on Meta. Community and Moderator guidelines for escalating issues via new response…. Feedback on Q2 Community Roadmap. Technical site integration observational experiment live on Stack Overflow. Dark Mode Beta - help us root out low-contrast and un-converted bits.
The problem is to display '0' for departments without no current students. Unfortunately, it wrongly displays '1' for departments like 'Law' without current students for the sample input. You can refer to the MySQL manual for the details. Count Student Number in Departments. Rate this article:. Most Votes. Newest to Oldest. Oldest to Newest. Login to Comment. May 17, AM. Read More.
How To Find The Highest Number Of Employees In a Department Using SQL Server
June 9, PM. Because the 'inner join' will miss the departments with no current students. May 23, AM. May 15, AM. February 4, AM. January 24, AM.Send the answers to wipro.
Thanks Administrator. Hi Karthi, i have sent the answers to the given email address. Pls post them here. Thanks, Suri. Hi Sarvanan, I have forwarded the doc please check.how to get highest salary in each department
HI Prassannaplease send the answers to mail id arpan. HI Prasanna, please send me too,my mail id nandeesh. Hi Prasanna, Can you please send the answers to my email id amritsh07 gmail.
Write your MySQL query statement below
Can you please send the answer of these questions on this mail ID munchun gmail. Hi Prasanna i developed some assignments i want to check my quries can u send answers at 2thesarath gmail. Guys ans have been sent to all the email id's provided here.
Hi All, As per your request i posted the answers as a post. Hi, Great. Tutorial is just awesome. It is really helpful for a newbie like me. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging. If anyone wants to become a Java developer learn from Java Training in Chennai. Nowadays Java has tons of job opportunities on various vertical industry. Java Online Training. This is a good post. This post give truly quality information. Really very useful tips are provided here.
Keep up the good works. Google Analytics. Anonymous Block. And print the results to screen. Use maximum dept number fetched from above and adds 10 to it.
I need to find the department s in which the maximum number of employees work. Please help. Just a little more verbose than the other two solutions, but it will get the job done This will give the department name of the department which is having maximum number of employees.
Now, I insert some entries in the table in such a manner that:. Learn more. Asked 4 years, 11 months ago. Active 6 months ago. Viewed 46k times. PdC 1, 9 9 silver badges 22 22 bronze badges.
Aditya Aditya 33 1 1 gold badge 1 1 silver badge 4 4 bronze badges. Active Oldest Votes. Try this query. You can try this query. Mahedi Sabuj Mahedi Sabuj 2, 3 3 gold badges 10 10 silver badges 22 22 bronze badges. If there are more than one departments with maximum number. How should I modify this query. Abhishek Sahay Abhishek Sahay 7 7 bronze badges. Pang 8, 16 16 gold badges 70 70 silver badges bronze badges.
Thanks Pang. I was going to edit. But, I had to go to somewhere. Now, I am back and your editing makes me happy. Alexander 3, 7 7 gold badges 17 17 silver badges 31 31 bronze badges.
It only takes a minute to sign up. Without adding the emp name I get the correct solution, but with the employee I get 1 in the num of employees. The "classical" way to achieve this using group by is the following. You have to introduce a second employee table that represents the colleagues of an employee in the same departments. So I have to use the IDs in the group by clause even if I do not display them.
But maybe there are ways using newer SQL constructs with better performance. It would be interesting to test it and compare it to the other answers. It is impossible for me to predict which query has the better performance. Oracle has a smart optimizer so there is no reason to expect that he does something in a slow way if a faster one exists.
Sign up to join this community. The best answers are voted up and rise to the top. Home Questions Tags Users Unanswered. Display department name,the number of employees and their names Ask Question. Asked 2 years, 11 months ago. Active 2 years, 11 months ago. Viewed 6k times. Grayson Grayson 1 1 1 silver badge 2 2 bronze badges. Active Oldest Votes.
The dark mode beta is finally here. Change your preferences any time. Stack Overflow for Teams is a private, secure spot for you and your coworkers to find and share information. If you did not need the actual department details, but just the department name you could simplify this further like so :.
Learn more. Asked 7 years, 10 months ago. Active 3 years, 7 months ago. Viewed 65k times. Share the schema and query you have tried. Without actually seeing your table structure I can only advise you count employees and group by department. Active Oldest Votes. Donovan Thomson Donovan Thomson 1, 1 1 gold badge 11 11 silver badges 20 20 bronze badges.
Tunaki k 27 27 gold badges silver badges bronze badges.
Sushmita Tiwari Sushmita Tiwari 1. Goodbye StackExchange Vikram Yenigalla Vikram Yenigalla 1 1 1 bronze badge. EmployeeName, d. DepartmentName, count d. The Overflow Blog. Featured on Meta. Community and Moderator guidelines for escalating issues via new response…. Feedback on Q2 Community Roadmap.
Technical site integration observational experiment live on Stack Overflow.