parsed.org

Tips by tag: count

Count by First Letter by xinu on Jan 10, 2008 02:16 PM

To get a count of rows by the first letter of the last name (lname):

sql> select count(1), substr(lname, 1, 1) as first from some_table group by first;

Thanks to McG for the tip.

countsqlsubstr
Finding Duplicates by xinu on Dec 14, 2007 10:31 AM

You need to determine if there are any duplicates in a column; here's a quick way to do that with a couple count() functions:

sql> select count(field), count(distinct field) from table where...

If the counts are the same, you're duplicate free!

Thanks to McG for the tip.

countdistinctduplicatesql
RSS