sql server - SQL returns less results when using UNION? -
I have a SQL Server stored procedure that does not give me all the results when I add to the union and in the second half . The first half will give me all 6 results of the union's use, I only get 5.
There are 3 patients [Chart Number], 2 items should be displayed in each If [CPTCode] is the same for both patients of a patient, then when adding union, only one of the two entries is shown (this gives me 6 with all [cptcode] without union) The second half is actually not pulling any information with what I am doing now, but it is necessary.
choose / * Patients with chart number * / b1. [Chart Number], 'First Name' in the form of 'First Name' as the 'First' name as '0', [new name], [original name], [last name] as '', 'latex' [first name] , ''). [Feature code]) as [feature], isnull (B1.DOS, '') as [dos], isnull (ins. [Name], lytec. [Primary code] [primary code] Isnull (b1. [CPTCode], '') as cptCode, isnull (b1 [units], '') [units], isnull (b1 [modifier], '') [modifier] ], Isnull (B1 [cptCodeOther], '') [cptCodeOther], isnull (as B1. [CptCode2], '') cptCode2, isnull (B1. [Units], '' As the name ['cptCodeOther2]' as ProviderName [Modits] , As '[Sandboxmr] left the .dbo.patient Lytec on B1 in joining [dbo]. [Billing] B1. [Chart number] = litech. [Chart number] left [sandboxmr] .dbo. [Address ] Address on Lytec [feature code] = address. [Code] left [sandboxm R] .db.o. [insurance] latex ins [primary code] = ins. [Code] where b1 [userid] = 54 and (B1. [Date]> = Convert (varchar (25), '2011- 8-31', 101) and B1. [Dated] = convert (varchar (25), '2011-8-31', 101) and p. [Dated] Why does this do this, and how can I fix it? I tried to add a different to the [cptcode] area, but of course it generates an error. Thanks for any help you can provide!
unions will eliminate duplicate rows, even if they are between two result sets Try or use UNION ALL instead of within a single result set.
Comments
Post a Comment