View Single Post
  #1 (permalink)  
Old 05-12-2008, 08:18 PM
schepsr schepsr is offline
Junior Member
 
Join Date: May 2008
Posts: 1
schepsr is on a distinguished road
Post ANY dialect question:

Show Distinct Values Along With Count


I have a table where there is a character field of 60 bytes with invalid data in the last four bytes of the field.
I want to see what is in these last four bytes along with a count of how many rows in the table contain them.

This query shows me what distinct values are contained in the last four bytes:
[sql]SELECT DISTINCT(SUBSTRING(CUSTOM_DATA,56,4))
FROM ....[/sql]

And this gives me the count of how many different distinct values there are:
[sql]SELECT COUNT(DISTINCT(SUBSTRING(CUSTOM_DATA,56,4)))
FROM ...[/sql]

What do I need to add to the first select statement to not only show what's in the last four bytes of the field, but to also tell me how many rows in the table contains them?
Reply With Quote

ANSWER(S):