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

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

SQL question

From: David <thump_at_cosmiccooler.org>
Date: Thu, 20 Jan 2005 11:09:33 -0800 (PST)
Message-ID: <48796.127.0.0.1.1106248173.squirrel@127.0.0.1>


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
Received on Thu Jan 20 2005 - 14:16:13 CST

Original text of this message

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