Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

sql - Getting lowest values in GROUP BY -


with test_data (   select 1 key, 1 a, 2 b dual union  --# lowest key=1   select 1 key, 2 a, 1 b dual union   select 2 key, 3 a, 3 b dual union  --# lowest key=2, lowest b   select 2 key, 3 a, 4 b dual union   select 2 key, 4 a, 5 b dual ) 

i'm trying group key, , retrieve lowest a , corresponding b (lowest b in case of ties), plus sum of bs:

       key             first_b      sum_b ---------- ---------- ---------- ----------          1          1          2          3          2          3          3         12 

i can realize sub-select

select key, min(a) a, first_b, sum(b) sum_b (   select key, a, b,          first_value(b) on (partition key order a, b) first_b   test_data ) group key, first_b 

but wonder if there way avoid sub-select, like

select key, a, sum(b) sum_b,        min( first_value(b) on (partition key order a, b) ) first_b test_data group key, 

which raises ora-30483: window functions not allowed here


thanks in advance, peter

are looking first/last aggregate functions? because of min function, ordering b on first_b column should redundant depends on how intend on using it.

with test_data (   select 1 key, 1 a, 2 b dual union  --# lowest key=1   select 1 key, 2 a, 1 b dual union   select 2 key, 3 a, 3 b dual union  --# lowest key=2, lowest b   select 2 key, 3 a, 4 b dual union   select 2 key, 4 a, 5 b dual ) select    key,    min(a) a,   min(b) keep (dense_rank first order a, b) first_b,   sum(b) sum_b test_data group key 

Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -