Blogger Text

My Aim to Provide you quality contents, Tips & Tricks, Software, Microsoft Office, Graphic Editing (Adobe PhotoShop, After Affects, Illustrator, inDesign) Corel Draw, Corel Video Studio, Cyberlink PowerDirector, Power ActionCinema, Tutorials about Blogging and VU Assignments, Quizes & GDB Solutions and Much More... at regular Basis
                                     ***    Kindly Subscribe our Official YouTube Channel "INFOPALACESS OFFICIAL-Tuts: in this channel we upload Programming (C,C++,C# JAVA, PHP), Web Development, Graphics Editing and Microsoft Office Step by Step Tutorials from bigginer to Advance Level. We also provide free online courses at our YouTube Channel. ***   Graded Assignments/Quizes and GDB will start in Next Week. Solution ideas of All assignments, Quizes and GDB will be available here. If you have any problem regarding this then you can contact us.

SQL COUNR & SUM QUERY : Count Total Number of Users, Registered Users and Blocked Users

COUNT SQL QUERY ADVANCE LEVEL

SUM and COUNT SQL QUERY to display Number of Counts of Registered, Rejectected, Active and Total Number of Registered Users from Database

Today i want to teach you that how u can get total number of Registered Students, Active Students and Blocked Students. Before starting i Just want to show you that i have table known as users_table in data base and i have table structure like below given picture;

I above given table i have total 4 registered users and out of 4 only 2 users or Active, 1 is in pending, 0 Rejected and 1 Users Account Status is Blocked here we have query to get this result.



sqlQuery = "select sum(case when status = 'Active' then 1 else 0 end) active," + " sum(case when status = 'Rejected' then 1 else 0 end) rejected," + " sum(case when status = 'Blocked' then 1 else 0 end) blocked," + " sum(case when status = 'Pending' then 1 else 0 end) pending," + "count(*) total from users_table";




Remember that Here my database table name is users_table and column name is status, but you can change it according to your table name and coloumn Name.....

Post a Comment

0 Comments