{"id":49,"date":"2008-05-02T20:48:48","date_gmt":"2008-05-03T01:48:48","guid":{"rendered":"http:\/\/www.cfchimp.com\/wordpress\/?p=49"},"modified":"2024-12-05T20:04:57","modified_gmt":"2024-12-06T01:04:57","slug":"a-few-sql-queries","status":"publish","type":"post","link":"https:\/\/csimmons.dev\/blog\/2008\/05\/a-few-sql-queries\/","title":{"rendered":"A few SQL queries"},"content":{"rendered":"<p>I had to do some basic analysis of email addresses at my company the other day.\u00ac\u0086 Here are a few useful SQL queries.<\/p>\n<p>Show 10 records with the most data in field &#8217;email&#8217; (10 longest email addresses)<br \/>\n<code><br \/>\nSELECT TOP 10 email, LEN(email) AS fieldLength<br \/>\nFROM person<br \/>\nORDER BY fieldLength DESC<br \/>\n<\/code><br \/>\nCount all records with field &#8217;email&#8217; over 20 chars<br \/>\n<code><br \/>\nSELECT COUNT(*) AS emailOver20<br \/>\nFROM person<br \/>\nWHERE LEN(email) &gt; 20<br \/>\n<\/code><br \/>\nDisplay the average length of data (in characters) of field &#8217;email&#8217;<br \/>\n<code><br \/>\nSELECT AVG(LEN(email)) AS emailAvgLength<br \/>\nFROM person<br \/>\n<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I had to do some basic analysis of email addresses at my company the other day.\u00ac\u0086 Here are a few useful SQL queries. Show 10 records with the most data in field &#8217;email&#8217; (10 longest email addresses) SELECT TOP 10 email, LEN(email) AS fieldLength FROM person ORDER BY fieldLength DESC Count all records with field &#8230; <a title=\"A few SQL queries\" class=\"read-more\" href=\"https:\/\/csimmons.dev\/blog\/2008\/05\/a-few-sql-queries\/\" aria-label=\"Read more about A few SQL queries\">Read more<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"_cloudinary_featured_overwrite":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[68],"tags":[12,16],"class_list":["post-49","post","type-post","status-publish","format-standard","hentry","category-developer","tag-developer","tag-sql"],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/pbVg43-N","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/csimmons.dev\/blog\/wp-json\/wp\/v2\/posts\/49","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/csimmons.dev\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/csimmons.dev\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/csimmons.dev\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/csimmons.dev\/blog\/wp-json\/wp\/v2\/comments?post=49"}],"version-history":[{"count":0,"href":"https:\/\/csimmons.dev\/blog\/wp-json\/wp\/v2\/posts\/49\/revisions"}],"wp:attachment":[{"href":"https:\/\/csimmons.dev\/blog\/wp-json\/wp\/v2\/media?parent=49"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/csimmons.dev\/blog\/wp-json\/wp\/v2\/categories?post=49"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/csimmons.dev\/blog\/wp-json\/wp\/v2\/tags?post=49"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}