Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Removing duplicate records from the resident table using distinct clause

Hi All,

I am trying to remove all the duplicates and bring in only distinct rows from the resident table below but it still is bringing in all the duplicates.  See below I have Noconcatenate clause used too.  Any leads will be very much appreciated

Thanks,

Monica

Table2:

NoConcatenate

Load

Distinct *

Resident Table1;

Drop Table Table1;

5 Replies
sunny_talwar
MVP
MVP

This should have only brought DISTINCT, but DISTINCT row of all your columns. Can you share a sample where this isn't working?

Not applicable
Author

Yes I will do it i another post as right now I am unable to retrieve anything from server but can you also let me know how can I get distinct rows based on some columns not all?  I was thinking if there is a syntax for where clause that would do that?

Thanks

Monica

nabhiram
Contributor III
Contributor III

Hi Monica,

Your code should work correctly. I tried with my own.

Table1:

LOAD * INLINE [

    A, B, C

    1, 1b, 1c

    2, 2b, 2c

    2, 2b, 2c

    3, 3b, 3c

    4, 4b, 4c

    4, 4b, 4c

    5, 5b, 5c

];

Table2:

NoConcatenate

Load

Distinct *

Resident Table1;

Drop Table Table1;

Output is:

Capture.JPG

Send your sample code, then we can find out what's wrong with it

Thanks

jagan
Partner - Champion III
Partner - Champion III

Hi,

If you give

LOAD DISTINCT *

Then the distinct is considered for all the columns but not for a single column.  For example

ID, Country

1, India

1, USA

If you give

LOAD DISTINCT *

FROM DataSource;

You will get both the rows even the ID is same, becase the country field is having different values.  If you just want one row  then

LOAD

*

FROM Datasource

WHERE Exists(ID);

It will just load only one row.

Regards,

Jagan.

swuehl
Champion III
Champion III

Monica Chhabra wrote:

Yes I will do it i another post as right now I am unable to retrieve anything from server but can you also let me know how can I get distinct rows based on some columns not all?  I was thinking if there is a syntax for where clause that would do that?

Thanks

Monica

Maybe like

Table:

LOAD

     Field1 & Field2 as Key,

     Field1,

     Field2,

     Field3

FROM ....

WHERE NOT EXISTS(Key, Field1 & Field2);

DROP FIELD Key;

Only first occurence of Key value will be loaded into the resident table. Field3 is not considered for distinctness.