SQL Scenario


hi ,

i looking below solution using sql .

create table #temp

( id varchar(10),

value int

)

insert #temp values('a',-9),('a',1),('b',-5),('b',3),('c',12),('c',-2)

input

                      output

id

value

id

pos value

neg value

a

-9

a

1

-9

a

1

b

3

-5

b

-5

c

12

-2

b

3

c

12

c

-2

thasnks in advace

regards,

vipin jha


thankx & regards, vipin jha mcp

try below:

create table #temp ( id varchar(10), value int ) insert #temp values('a',-9),('a',1),('b',-5),('b',3),('c',12),('c',-2)  select id, max(case when value >0 value else null  end), max(case when value <0 value else null  end) #temp group id  drop table #temp



SQL Server  >  Getting started with SQL Server



Comments

Popular posts from this blog

Motherboard replacement

Cannot create Full Text Search catalog after upgrading to V12 - Database is not fully started up or it is not in an ONLINE state

Remote Desktop App - Error 0x207 or 0x607