Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> Re: SQL question

Re: SQL question

From: Chris Stephens <cstephens16_at_gmail.com>
Date: Thu, 20 Jan 2005 14:26:22 -0500
Message-ID: <d95e8607050120112662f00eef@mail.gmail.com>


select b.* , cout_of_rows, max_rows
from
(select count(*) as count_of_rows, max(c_level) as max_rows

   from ch_st
   where active = 1
   and a_id = 99999) a,
 ch_st b
where a.c_level = b.c_level and
  a.active=1 and
  b.a_id = 99999

??

On Thu, 20 Jan 2005 11:09:33 -0800 (PST), David <thump_at_cosmiccooler.org> wrote:
> How can I accomplish the following...the problem is a bit beyond my SQL
> skills:
>
> select
> a_id,
> c_name,
> c_id,
> c_level,
> e_d,
> t_c,
> t_l,
> a_s,
> g_t,
> s_x,
> s_x,
> c_a,
> t_cd,
> c_a,
> n_k
> from ch_st c
> where
> active = 1
> and c.a_id = 99999
>
> Based on two conditions(active and a_id =), the select will return 1 or
> more rows.
>
> The final output should list the columns in the select above, BUT only 1
> row should be outpouted and that row should list a count of the number of
> rows matching the criteria and the max c_level in the rows returned and
> the associated columns.
>
> So, simple query above returns say 4 rows....final query should return 1
> row and perform a count and a max on a column and only list the columns
> associated with that max value...
>
> I hope that makes sense...I know max, group_by, etc are in the mix, but...
>
> LOL
> ;)
> --
> ..
> David
>
> --
> http://www.freelists.org/webpage/oracle-l
>

--
http://www.freelists.org/webpage/oracle-l
Received on Thu Jan 20 2005 - 14:36:41 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US