Fellow Monks, I come to you with limited sql power and mediocre perl knowledge asking you for your help in finishing this question. I am attempting to get a count of users in a database that fall into one of three categories. It is a decibel recording DB that keeps track at the levels at which modems are speaking on a RF network, in dB of course. The 3 groups are less then 30, 30-40, and 40 plus dB.
The current way I am doing it is with a mixture of the following sql:
my $sql = "select power_level, decode(power_level,null,'NA',decode(sig +n(power_level-30),-1,'1', decode(sign(power_level-40),1,'2','3'))) from wbr_power where host_name in ( select host_name from hosts where market_id = '$market' )";
And the following perl doing simple iterations on the array returned :
my ($lessThan, $inBetween, $greaterThan) = 0; foreach my $code (@powerCodes) { if ($code->[1] eq '1'){ $lessThan++; }elsif ($code->[1] eq '2'){ $inBetween++; }elsif ($code->[1] eq '3'){ $greaterThan++; } }
There must be someway through joins and count() or sum() to do this all on the oracle end. But like I said, still pretty wet in the SQL relm. Please help.


Tradez
"Never underestimate the predicability of stupidity"
- Bullet Tooth Tony, Snatch (2001)

In reply to Whether to perl or oracle by tradez

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.