Not so much that I know, I'm afraid. Usually I do:
def distinct_count <<-EOF.gsub /^\s+/, "" \tSELECT \t CAST('#{name}' AS VARCHAR(30)) as COLUMN_NAME \t,COUNT(DISTINCT
It works, but a little hacked.
EDIT: Taking inspiration from Rene Saarsoo below, I would suggest something like this:
class String def unindent gsub(/^#{scan(/^\s*/).min_by{|l|l.length}}/, "") end end def distinct_count <<-EOF.unindent \tSELECT \t CAST('#{name}' AS VARCHAR(30)) as COLUMN_NAME \t,COUNT(DISTINCT #{name}) AS DISTINCT_COUNT \tFROM #{table.call} EOF end
This version should be processed if the first line is not one of the farthest to the left.
einarmagnus Sep 22 '10 at 19:30 2010-09-22 19:30
source share