Hi Friends
How to do sum on a column?
I have a file like:
FRED 500.01 TX
SMITH 50.10 NY
HARRY 5.00 CA
555.11
Sum on second column.
I am trying using nawk like
nawk 'BEGIN {FS="|"}; {printf $1"+"}'
Thanks a lot for your help
S :) (2 Replies)
I have a text file with two columns
the first column is an integer and the second column is date
how do i sum up the first column according to the date
example
123 jan1
232 jan1
473 jan2
467 jan2
356 jan3
376 jan3
my result should be
355 jan1
940 jan2
732 jan3
how do i... (2 Replies)
I have a file which contains data as below:
-----------------------------------------------------------------------------------------------
GSPWeb Statistics for the period of last 20 days... (3 Replies)
Dear all,
I have one file like
LABEL A B C D E F G H I J K L M N
G02100 64651.3 25630.7 8225.21 51238 267324 268005 234001 52410.9 18598.2 10611 10754.7 122535 267170 36631.4
G02100 12030.3 8260.15 8569.91 ... (4 Replies)
a,b,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,aa,bb,cc,dd,ee,ff,gg,hh,ii
a thru ii are digits and strings....
The awk needed....if coloumn 9 == i (coloumn 9 is string ), output the sum of x's(coloumn 22 ) in all records and sum of y's (coloumn 23 ) in all records in a file (records.txt).... (6 Replies)
Hi,
I have a requirement like below.
client is sending the .txt filles.In that file we have 10 records but when I execute the below command it is showing 9 records.
klena20> wc -l sample_file.txt|awk '{print $1}'
It is showing the output as 9
But in a file records are 10. I found... (7 Replies)
hi All,
i have a file in which only one column is there.,
test.txt
======
-900.01
-900.02
-900.03
-900.04
-900.05
-900.06
-900.07
-900.08
-900.09
900.01
900.02
900.03
900.04
900.05 (4 Replies)
Hi Everyone,
I am comparing results of two environments using unix files.
I am writing two different csv file using spool and merging both the files using paste command
paste -d, file1.csv file2.csv > prod_uat_result.csv
and then finding the difference and attaching the same in a mail... (8 Replies)
Discussion started by: karthik adiga
8 Replies
LEARN ABOUT MOJAVE
dbix::class::resultsetcolumn
DBIx::Class::ResultSetColumn(3) User Contributed Perl Documentation DBIx::Class::ResultSetColumn(3)NAME
DBIx::Class::ResultSetColumn - helpful methods for messing
with a single column of the resultset
SYNOPSIS
$rs = $schema->resultset('CD')->search({ artist => 'Tool' });
$rs_column = $rs->get_column('year');
$max_year = $rs_column->max; #returns latest year
DESCRIPTION
A convenience class used to perform operations on a specific column of a resultset.
METHODS
new
my $obj = DBIx::Class::ResultSetColumn->new($rs, $column);
Creates a new resultset column object from the resultset and column passed as params. Used internally by "get_column" in
DBIx::Class::ResultSet.
as_query
Arguments: none
Return Value: [ $sql, @bind_values ]
Returns the SQL query and bind vars associated with the invocant.
This is generally used as the RHS for a subquery.
next
Arguments: none
Return Value: $value
Returns the next value of the column in the resultset (or "undef" if there is none).
Much like "next" in DBIx::Class::ResultSet but just returning the one value.
all
Arguments: none
Return Value: @values
Returns all values of the column in the resultset (or "undef" if there are none).
Much like "all" in DBIx::Class::ResultSet but returns values rather than result objects.
reset
Arguments: none
Return Value: $self
Resets the underlying resultset's cursor, so you can iterate through the elements of the column again.
Much like "reset" in DBIx::Class::ResultSet.
first
Arguments: none
Return Value: $value
Resets the underlying resultset and returns the next value of the column in the resultset (or "undef" if there is none).
Much like "first" in DBIx::Class::ResultSet but just returning the one value.
single
Arguments: none
Return Value: $value
Much like "single" in DBIx::Class::ResultSet fetches one and only one column value using the cursor directly. If additional rows are
present a warning is issued before discarding the cursor.
min
Arguments: none
Return Value: $lowest_value
my $first_year = $year_col->min();
Wrapper for ->func. Returns the lowest value of the column in the resultset (or "undef" if there are none).
min_rs
Arguments: none
Return Value: $resultset
my $rs = $year_col->min_rs();
Wrapper for ->func_rs for function MIN().
max
Arguments: none
Return Value: $highest_value
my $last_year = $year_col->max();
Wrapper for ->func. Returns the highest value of the column in the resultset (or "undef" if there are none).
max_rs
Arguments: none
Return Value: $resultset
my $rs = $year_col->max_rs();
Wrapper for ->func_rs for function MAX().
sum
Arguments: none
Return Value: $sum_of_values
my $total = $prices_col->sum();
Wrapper for ->func. Returns the sum of all the values in the column of the resultset. Use on varchar-like columns at your own risk.
sum_rs
Arguments: none
Return Value: $resultset
my $rs = $year_col->sum_rs();
Wrapper for ->func_rs for function SUM().
func
Arguments: $function
Return Value: $function_return_value
$rs = $schema->resultset("CD")->search({});
$length = $rs->get_column('title')->func('LENGTH');
Runs a query using the function on the column and returns the value. Produces the following SQL:
SELECT LENGTH( title ) FROM cd me
func_rs
Arguments: $function
Return Value: $resultset
Creates the resultset that "func()" uses to run its query.
throw_exception
See "throw_exception" in DBIx::Class::Schema for details.
AUTHOR AND CONTRIBUTORS
See AUTHOR and CONTRIBUTORS in DBIx::Class
LICENSE
You may distribute this code under the same terms as Perl itself.
perl v5.18.2 2014-01-23 DBIx::Class::ResultSetColumn(3)