|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
I'm trying to write a query that will return rows within a specified range and print to a Crystal Report. When I run the query, it produces 2 row of everything. I would use the SELECT DISTINCT clause, but Crystal Reports will not let me edit the Select statement. But I can edit the FROM, WHERE and ORDER BY clauses. I think the problem is in my INNER JOINS but I'm having a problem figuring it out. Can someone please guide me in the right direction.
SELECT DrawingVouchers."PlayerID", DrawingVoucherNumbers."PromoID", DrawingVoucherNumbers."VoucherNumber", DrawingVoucherNumbers."IssueDate", DrawingVoucherNumbers."UserID", CDS_PLAYER."LastName", CDS_PLAYER."FirstName", CDS_ACCOUNT."Address1A", CDS_ACCOUNT."City1", CDS_ACCOUNT."State1", CDS_ACCOUNT."Zip1" FROM { oj (("WinOasis"."dbo"."DrawingVouchers" DrawingVouchers INNER JOIN "WinOasis"."dbo"."DrawingVoucherNumbers" DrawingVoucherNumbers ON DrawingVouchers."PlayerID" = DrawingVoucherNumbers."PlayerID") INNER JOIN "WinOasis"."dbo"."CDS_PLAYER" CDS_PLAYER ON DrawingVoucherNumbers."PlayerID" = CDS_PLAYER."Player_ID") INNER JOIN "WinOasis"."dbo"."CDS_ACCOUNT" CDS_ACCOUNT ON CDS_PLAYER."Player_ID" = CDS_ACCOUNT."Primary_ID"} WHERE DrawingVoucherNumbers."VoucherNumber" >= 37806 AND DrawingVoucherNumbers."VoucherNumber" <= 37813 |
|
#2
|
||||
|
||||
|
I really dislike the way Crystal formats queries, but I guess I'm just anti-Crystal.
DISTINCT won't really work on this. The problem most likely lies in your INNER JOINs. The only way I know of to get around this is to increase the criteria in WHERE so that it won't perceive two records. Either way, you're going to have to edit your query in the end, unfortunately. |
|
#3
|
|||
|
|||
|
Answer
It appears that I had a table that wasn't needed. the drawingVouchers table dosent appear to do anything. I took it out, then ran query. I got no duplicates
|
![]() |
| Viewing: Dev Shed Forums > Databases > MS SQL Development > Query returning duplicate rows |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|