Mysql count
Upcoming SlideShare
Loading in...5
×
 

Like this? Share it with your network

Share

Mysql count

on

  • 725 views

MySQL COUNT() function returns a count of number of non-NULL values of a given expression.

MySQL COUNT() function returns a count of number of non-NULL values of a given expression.

If it does not find any matching row, it returns 0.

Statistics

Views

Total Views
725
Views on SlideShare
725
Embed Views
0

Actions

Likes
0
Downloads
0
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as OpenOffice

Usage Rights

CC Attribution License

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Mysql count Presentation Transcript

  • 1. MySql COUNT() function Ref: w3resource MySQL Tutorial
  • 2. MySQL Count function MySQL COUNT() function returns a count of numberof non-NULL values of a given expression. If it does not find any matching row, it returns 0. Here is the Syntax: COUNT(expr); We will see different types of usage of MySQLCount function in a moment.
  • 3. MySQL Count functionTable for demonstration:
  • 4. MySQL Count functionTo return the number of rows in author table: SELECT COUNT(*) FROM author;MySQL COUNT() with logical operator: SELECT country,pub_city,COUNT(*) FROM publisher WHERE country=USA OR country=UK GROUP BY country,pub_city;
  • 5. MySQL Count functionMySQL COUNT() using multiple tables: Table book_mast
  • 6. MySQL Count functionMySQL COUNT() using multiple tables:Table book_mast
  • 7. MySQL Count function SELECT publisher.pub_name,COUNT(*) FROM publisher,book_mast WHERE publisher.pub_id=book_mast.pub_id GROUP BY publisher.pub_id; MySQL COUNT() function with GROUP BY SELECT country,COUNT(*) FROM author GROUP BY country; MySQL COUNT() function with group by on multiple columns SELECT country,pub_city,COUNT(*) FROM publisher GROUP BY country,pub_city;
  • 8. MySQL Count functionMySQL COUNT() function with distinct SELECT cate_id,COUNT(DISTINCT(pub_lang)), ROUND(AVG(no_page),2) FROM book_mast GROUP BY cate_id;