Select distinct returns duplicates

Cove

I have the following query:

SELECT 
DISTINCT (TK.TICKETID),
TK.DESCRIPTION,
TK.CREATIONDATE,
TK.REPORTEDBY,
TK.OWNER,
WF.ASSIGNCODE
FROM ticket TK
INNER JOIN wfassignment WF on WF.OWNERID = TK.TICKETUID
WHERE TK.status not in ('ЧЕРНОВИК', 'ЗАКРЫТ', 'ВЫПОЛНЕН') AND WF.ASSIGNSTATUS not in ('COMPLETE', 'INACTIVE')
ORDER BY TK.TICKETID;

But it returns duplicates in TK.TICKETID attribute. And if i remove other attributes all ok. e.g.

TK.TICKETID TK.DESCRIPTION TK.CREATIONDATE  TK.REPORTEDBY  TK.OWNER     WF.ASSIGNCODE
О1013249    Право доступа   02.06.14        CHERNOVDK      SKACHKOVSV   NOVIKOVVA
О1013249    Право доступа   02.06.14        CHERNOVDK      SKACHKOVSV   PRITULADV
О1013249    Право доступа   02.06.14        CHERNOVDK      SKACHKOVSV   SVESHNIKOVAV

M.b. my question is simple but I can't solve it by myself. Will be greatfull for any kind of help.

Horaciux

Try this:

SELECT 
TK.TICKETID,
TK.DESCRIPTION,
TK.CREATIONDATE,
TK.REPORTEDBY,
TK.OWNER,
max(WF.ASSIGNCODE)
FROM ticket TK
INNER JOIN wfassignment WF on WF.OWNERID = TK.TICKETUID
WHERE TK.status not in ('ЧЕРНОВИК', 'ЗАКРЫТ', 'ВЫПОЛНЕН') AND WF.ASSIGNSTATUS not in ('COMPLETE', 'INACTIVE')
group by
TK.TICKETID,
TK.DESCRIPTION,
TK.CREATIONDATE,
TK.REPORTEDBY,
TK.OWNER
ORDER BY TK.TICKETID;

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Select distinct values of distinct group

From Dev

Check for duplicates before adding, or just select distinct when finished?

From Dev

SELECT DISTINCT still showing duplicates

From Dev

Select all but ignore duplicates

From Dev

SELECT DISTINCT returns duplicates - no table JOIN

From Dev

What is the difference between SELECT * and returning all columns by specfying each in the Select statement / Union query returns Duplicates

From Dev

GROUP or DISTINCT after JOIN returns duplicates

From Dev

Remove duplicates in list using Distinct

From Dev

Eliminate duplicates in select with php

From Dev

How to select only distinct row when there might be duplicates using SQL?

From Dev

ORACLE SQL select distinct not removing duplicates

From Dev

MongoDB Select distinct - returns more files

From Dev

SPARQL DISTINCT gives duplicates in Virtuoso

From Dev

SELECT with different column order and distinct WHERE conditions returns more rows than total count of rows

From Dev

MYSQL - Select count of all rows that are duplicates in 1 column and distinct in another column

From Dev

SELECT COUNT(*) DISTINCT - Finding the total number of times any groups of duplicates appear in a table

From Dev

Select all entries with no duplicates?

From Dev

SELECT DISTINCT CAST (CASE (WHEN X IN)) THEN 1 ELSE 0 END AS BIT) AS INTO Returns Duplicate Records

From Dev

Select duplicates in SQL

From Dev

Distinct returning duplicates with multiple columns

From Dev

ORACLE SQL select distinct not removing duplicates

From Dev

Oracle Select JOIN Listagg. Duplicates in the output. Using Distinct or other

From Dev

Count distinct duplicates

From Dev

PostgreSQL: SELECT DISTINCT vs SELECT DISTINCT ON (id)

From Dev

Remove duplicates from select

From Dev

How to display DISTINCT duplicates SQL

From Dev

Avoid duplicates in SELECT

From Dev

Observable distinctUntilChanged returns duplicates

From Dev

DISTINCT key but it returns duplicates; Query with multiple JOINS - Bug in my WHERE statement?

Related Related

  1. 1

    Select distinct values of distinct group

  2. 2

    Check for duplicates before adding, or just select distinct when finished?

  3. 3

    SELECT DISTINCT still showing duplicates

  4. 4

    Select all but ignore duplicates

  5. 5

    SELECT DISTINCT returns duplicates - no table JOIN

  6. 6

    What is the difference between SELECT * and returning all columns by specfying each in the Select statement / Union query returns Duplicates

  7. 7

    GROUP or DISTINCT after JOIN returns duplicates

  8. 8

    Remove duplicates in list using Distinct

  9. 9

    Eliminate duplicates in select with php

  10. 10

    How to select only distinct row when there might be duplicates using SQL?

  11. 11

    ORACLE SQL select distinct not removing duplicates

  12. 12

    MongoDB Select distinct - returns more files

  13. 13

    SPARQL DISTINCT gives duplicates in Virtuoso

  14. 14

    SELECT with different column order and distinct WHERE conditions returns more rows than total count of rows

  15. 15

    MYSQL - Select count of all rows that are duplicates in 1 column and distinct in another column

  16. 16

    SELECT COUNT(*) DISTINCT - Finding the total number of times any groups of duplicates appear in a table

  17. 17

    Select all entries with no duplicates?

  18. 18

    SELECT DISTINCT CAST (CASE (WHEN X IN)) THEN 1 ELSE 0 END AS BIT) AS INTO Returns Duplicate Records

  19. 19

    Select duplicates in SQL

  20. 20

    Distinct returning duplicates with multiple columns

  21. 21

    ORACLE SQL select distinct not removing duplicates

  22. 22

    Oracle Select JOIN Listagg. Duplicates in the output. Using Distinct or other

  23. 23

    Count distinct duplicates

  24. 24

    PostgreSQL: SELECT DISTINCT vs SELECT DISTINCT ON (id)

  25. 25

    Remove duplicates from select

  26. 26

    How to display DISTINCT duplicates SQL

  27. 27

    Avoid duplicates in SELECT

  28. 28

    Observable distinctUntilChanged returns duplicates

  29. 29

    DISTINCT key but it returns duplicates; Query with multiple JOINS - Bug in my WHERE statement?

HotTag

Archive