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;
Comments
Post a Comment