Skip to content

Instantly share code, notes, and snippets.

@dannguyen
Last active August 29, 2015 13:57
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save dannguyen/9921769 to your computer and use it in GitHub Desktop.
find distribution of value lengths for a given field
SET @field_name = "place_of_service";
SET @tablename = "payments";
SET @query = CONCAT('SELECT ', @field_name, ', count(1), length(', @field_name, ') AS lt FROM ', @tablename,' GROUP BY ', @field_name, ' ORDER BY lt desc');
PREPARE stmt FROM @query;
EXECUTE stmt;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment