Search code examples
sqlpervasivepervasive-sql

Create View while preemptively removing duplicate rows


I am trying to create a self-executing Pervasive SQL (PSQL) view command that can preemptively remove duplicate rows from a table on-the-fly. The basic command to create a single column table view is as follows:

 CREATE VIEW "VIEW_EMP" AS SELECT "ATTENDANCE" . "EMPLOYEE" FROM "TIME_ATTENDANCE" 

I am wondering if anyone has any ideas how to implement any means of avoiding duplicate appends of the EMPLOYEE field? As you can see above, the name of the source table is ATTENDANCE and the name of the destination table (view) will be VIEW_EMP.

I've found that PSQL is very similar to MySQL so even if you don't know PSQL perhaps you can still answer this question. I found this post using the MySQL DELETE command, but I don't know if it is applicable in my particular case.


Solution

  • In most versions of SQL you would use

    SELECT DISTINCT ATTENDANCE.EMPLOYEE
    FROM TIME_ATTENDANCE 
    

    or

    SELECT ATTENDANCE.EMPLOYEE 
    FROM TIME_ATTENDANCE 
    GROUP BY EMPLOYEE
    

    Did you try one of these?