sql - Force query to deliver duplicate results based off WHERE values -


i have been asked add few columns report based on account number.

the problem several accounts listed more once in report.

the report has on 500 rows, 450 account numbers.

is there way force results give me duplicate data?

example:

select a.accountnumber, a.programflag, a.applicationstatus  accountinfo  a.accountnumber in ('100','101','101','101','102','102','103')  order a.accountnumber asc 

results:

accountnumber | program flag | applicationstatus ------------------------------------------------ 100           |      1       |     installed 101           |      0       |     closed 102           |      1       |     installed 103           |      0       |     installed 

desired results:

accountnumber | program flag | applicationstatus ------------------------------------------------ 100           |      1       |     installed 101           |      0       |     closed 101           |      0       |     closed 101           |      0       |     closed 102           |      1       |     installed 102           |      1       |     installed 103           |      0       |     installed 

the desired results easier add custom report repeating information accounts appear more once. 1 500+ records.

you can't add rows in clause can use numbers in derived table , join against that.

select   a.accountnumber,   a.programflag,   a.applicationstatus   dbo.accountinfo inner join    (values('100'),('101'),('101'),('101'),('102'),('102'),('103')) t(accountnumber) on   a.accountnumber = t.accountnumber order   a.accountnumber asc; 

sql fiddle


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -