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.

write a query to display the block number and number of departments in each block

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?

By using if condition you can create grid view, this part is added to the main contain of this page. How to find highest value in the table where no total column we need to find highest without having total column. Post your commentssuggestionerrorrequirements etc here.By using our site, you acknowledge that you have read and understand our Cookie PolicyPrivacy Policyand our Terms of Service.

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:.

write a query to display the block number and number of departments in each block

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.

Related Hot Network Questions. Question feed. Stack Overflow works best with JavaScript enabled.A university uses 2 data tables, student and departmentto store data about its students and the departments associated with each major. Write a query to print the respective department name and number of students majoring in each department for all departments in the department table even ones with no current students. Sort your results by descending number of students; if two or more departments have the same number of students, then sort those departments alphabetically by department name.

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.

write a query to display the block number and number of departments in each block

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.

Leave the location AS null. Use substitution variable for dept no. Print to the screen the number of rows affected. Employee name, PF and net salary. Use case expression.By using our site, you acknowledge that you have read and understand our Cookie PolicyPrivacy Policyand our Terms of Service. 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.

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.

Neeraj vishwakarma Neeraj vishwakarma 79 6 6 bronze badges. Omid Ziyaee Omid Ziyaee 3 3 silver badges 15 15 bronze badges. Peter Tretyakov 2, 6 6 gold badges 28 28 silver badges 45 45 bronze badges.By using our site, you acknowledge that you have read and understand our Cookie PolicyPrivacy Policyand our Terms of Service. Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community.

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.

You need to fetch the number of employees in a sub-query and then use this: select q. Marco Marco 3, 3 3 gold badges 18 18 silver badges 24 24 bronze badges. I changed my sub query. Use outer join if needed employees without departments, departments without employees. Balazs Papp Balazs Papp By using our site, you acknowledge that you have read and understand our Cookie PolicyPrivacy Policyand our Terms of Service.

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.

write a query to display the block number and number of departments in each block

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.


Comments on “Write a query to display the block number and number of departments in each block