Results are giving me 5 rows instead of 1 row

Hi

I have created a query that is suppose to display the results of opportunities won during a time period the user selects.

When I run the report, I get 5 rows of the exact same result.

How come I am getting this?

How do I fix this please?

DECLARE @DateStart		DATE		  = '2011/02/25';
DECLARE @DateEnd		DATE		  = '2015/12/27';
DECLARE @User			VARCHAR(100)  = 'Linda Smith';


SELECT 
OPP.customeridname		AS 'Customer Name',
OPP.contactidname       AS 'Contact Name',
OPP.actualclosedate		AS 'Actual Close Date',
OPP.actualvalue			AS 'Actual Value',
OPP.createdbyname		AS 'Created By Name',
OPP.createdby			AS 'Created By ID',

TBU.businessunitidname	AS 'Business Unit Name',
TBU.businessunitid		AS 'Business Unit ID'


FROM dbo.FilteredOpportunity AS OPP
INNER JOIN dbo.FilteredUserSettings AS TBU ON OPP.createdby = TBU.createdby


WHERE OPP.actualclosedate BETWEEN @DateStart AND @DateEnd

ORDER BY TBU.businessunitid ASC;


July 30th, 2015 2:24pm

I think it's because you are not filtering based on the @user parameter.

Free Windows Admin Tool Kit Click here and download it now
July 30th, 2015 2:28pm

Please provider example data and DDL. We can only make guesses with what you've given us so far.
July 30th, 2015 2:55pm

Thank you everyone

I have figured it out

  • Proposed as answer by JJordheim 11 hours 56 minutes ago
  • Marked as answer by katiemackie 11 hours 53 minutes ago
Free Windows Admin Tool Kit Click here and download it now
July 30th, 2015 3:03pm

Use Distinct if  all columns have same value ...

the reason for this this more than one records/duplicates are available in one of the table

July 30th, 2015 4:00pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics