kingberrill of SQL
6/11/2017 - 11:45 AM

COUNT()

COUNT()

-- To count rows you can use the COUNT() function.
SELECT COUNT(*) FROM <table>;

-- To count unique entries use the DISTINCT keyword too:
SELECT COUNT(DISTINCT <column>) FROM <table>;

-- count and alias column
select COUNT(*) as "scifi_book_count" from books where genre = "Science Fiction";