sql - subquery to derive a value if all values of the column is the same for -
hi have situation here oracle sql come out sql result next :-
company no of employees grouping derived field 1 x b 1 x c 2 y d 1 y
so based on grouping if company has same no of employees want derived field true else false.
so grouping x , if company , b has same no of employees derived field , b true. c , d because no of employees different derived field should false.
any help appreciated. thanks
you want utilize analytic function. think want:
select t.*, (case when min(numemployees) on (partition grp) = max(numemployees) on (partition grp) 1 else 0 end) derivedfield table t;
note: represent booleans 0 , 1.
sql oracle
No comments:
Post a Comment