SQL Grouping SUM


 
Thread Tools Search this Thread
Top Forums Programming SQL Grouping SUM
# 8  
Old 01-04-2012
Thanks both! I'll analyze your select since my one have some problem when day change (the first 6 chars)! :-)

...and yes, I'm using MySQL and bash script, but as rbatt1 said, I would save processing time to get the database to perform all the work! Database is not on the same machine, so I save also CPU usage! Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Grouping and counting

Hello, I would like to group/sort a file of records by a particular field and then count how many records belong in that grouping. For example say I have the following data: 1234|"ZZZ"|"Date"|"1"|"Y"|"ABC"|""|AA ABCD|"ZZZ"|"Date"|"1"|"Y"|"ABC"|""|AA EFGH|"ZZZ"|"Date"|"1"|"Y"|"ABC"|""|BB... (14 Replies)
Discussion started by: Nik44
14 Replies

2. Shell Programming and Scripting

Name grouping

awk 'FNR==NR {a; next} $NF in a' genes.txt refseq_exons.txt > output.txt I can not figure out how to group the same name in $4 together. Basically, all the SKI together in separate rows and all the TGFB2. Thank you :). chr1 2160133 2161174 SKI chr1 218518675 218520389 TGFB2... (1 Reply)
Discussion started by: cmccabe
1 Replies

3. Shell Programming and Scripting

Grouping output with sum

Hi Gurus, I would like to do in a script something that is really easy in sql. Basically, I have a file with a fomat like the following: name1_test 501 name 1 33 510 test2 900 name1_test 300 So, I would like to group them as... (3 Replies)
Discussion started by: ocramas
3 Replies

4. Shell Programming and Scripting

Grouping

Hi all, I am using following command: perl program.pl input.txt output.txt CUTOFF 3 > groups_3.txt containing program.pl, two files (input.txt, output.txt) and getting output in groups_3.txt: But, I wish to have 30 files corresponding to each CUTOFF ranging from 0 to 30 using the same... (1 Reply)
Discussion started by: bioinfo
1 Replies

5. UNIX for Dummies Questions & Answers

Grouping in grep

How do you do grouping in grep? Here's how I tried it at first: egrep 'qualit(y|ies)' /usr/share/dict/words -bash: syntax error near unexpected token `(' I'm using GNUgrep, and I found this on their site. grep regular expression syntax So I tried this: egrep 'qualit\(y\|ies\)'... (2 Replies)
Discussion started by: sudon't
2 Replies

6. Shell Programming and Scripting

PERL : SQL array bind issue while grouping

Hi, I have an array of strings. Each string has 4 comma separated values. I am binding this array to a SQL where I am required to do an INSERT after grouping. The binding is done as : $insertADWSth->bind_param_array(1,A_CONSTANT_STRING);... (1 Reply)
Discussion started by: sinpeak
1 Replies

7. Shell Programming and Scripting

Print sum and relative value of the sum

Hi i data looks like this: student 1 Subject1 45 55 Subject2 44 55 Subject3 33 44 // student 2 Subject1 45 55 Subject2 44 55 Subject3 33 44 i would like to sum $2, $3 (marks) and divide each entry in $2 and $3 with their respective sums and print for each student as $4 and... (2 Replies)
Discussion started by: saint2006
2 Replies

8. UNIX for Dummies Questions & Answers

grouping and sorting??

how would I write a command line that creates a new file named stuff.txt in the current working directory which contains the number of directories in the current working directory, followed by the number of empty files in the current working directory, followed by the name of the working directory? (3 Replies)
Discussion started by: jorogon0099
3 Replies
Login or Register to Ask a Question
SELECTALL_XML(1p)					User Contributed Perl Documentation					 SELECTALL_XML(1p)

NAME
stag-selectall_xml - Query all elements from database with an XML output SYNOPSIS
stag-selectall_xml [-d <dbi>] [-f file of sql] [-nesting|n <nesting>] SQL DESCRIPTION
This script will query a database using either SQL provided by the script user, or using an SQL templates; the query results will be turned into XML using the DBIx::DBStag module. The nesting of the XML can be controlled by the DBStag SQL extension "USE NESTING..." EXAMPLES stag-selectall_xml -d "dbi:Pg:dbname=mydb;host=localhost" "SELECT * FROM a NATURAL JOIN b" TEMPLATES A parameterized SQL template (canned query) can be used instead of specifying the full SQL For example: stag-selectall_xml -d genedb /genedb-gene gene_symbol=Adh Or: stag-selectall_xml -d genedb /genedb-gene Adh Or: stag-selectall_xml -d genedb /genedb-gene gene_symbol@=Adh,dpp,bam,indy A template is indicated by the syntactic shorthand of using a slash to precede the template name; in this case the template is called genedb-gene. the -t option can also be used. All the remaining arguments are passed in as SQL template parameters. They can be passed in as either name=value pairs, or as a simple list of arguments which get passed into the template in order To use templates, you should have the environment variable DBSTAG_TEMPLATE_DIRS set. See DBIx::DBStag for details. LISTING AVAILABLE TEMPLATES FOR A DB stag-selectall_xml -d mydb -h LISTING VARIABLES FOR A TEMPLATE stag-selectall_xml /genedb-gene -h ENVIRONMENT VARIABLES
DBSTAG_DBIMAP_FILE A file containing configuration details for local databases DBSTAG_TEMPLATE_DIRS list of directories (separated by :s) to be searched when templates are requested COMMAND LINE ARGUMENTS
-h|help shows this page if no other arguments are given if a template is specified, gives template details if a db is specified, lists templates for that db use in conjunction with -v for full descriptions -d|dbname DBNAME this is either a full DBI locator string (eg dbi:Pg:dbname=mydb;host=localhost) or it can also be a shortened "nickname", which is then looked up in the file pointed at by the environment variable DBSTAG_DBIMAP_FILE -u|user USER database user identity -p|password PASS database password -f|file SQLFILE this is a path to a file containing SQL that will be executed, as an alternative to writing the SQL on the command line -n|nesting NESTING-EXPRESSIONS a bracketed expression indicating how to the resulting objects/XML should be nested. See DBIx::DBStag for details. -t|template TEMPLATE-NAME the name of a template; see above -wh|where WHERE-CLAUSE used to override the WHERE clause of the query; useful for combining with templates You can append to an existing where clause by using the prefix + -s|select SELECT-COLS used to override the SELECT clause of the query; useful for combining with templates -rows sometimes it is preferable to return the results as a table rather than xml or a similar nested structure. specifying -rows will fetch a table, one line per row, and columns separated by tabs -pre SQL a piece of SQL is that is executed immediately before the main query; e.g.: -pre "SET search_path=myschema,public" -o|out FILE a file to output the results to -w|writer WRITER writer class; can be any perl class, or one of these xml [default] sxpr lisp S-Expressions itext indented text -color shows results in color (sxpr and itext only) -show will show the parse of the SQL statement perl v5.12.4 2011-10-14 SELECTALL_XML(1p)