Exists
(Employee)
|
Returnerar -1 (True) om fältets värde Employee i den aktuella posten redan finns i en tidigare läst post som innehåller detta fält.
|
Exists(Employee,
'Bill')
|
Returnerar -1 (True) om fältvärdet 'Bill' hittas i det aktuella innehållet i fältet Employee.
Satserna Exists (Employee, Employee) och Exists (Employee) är ekvivalenta.
|
Employees:
LOAD * inline [
Employee|ID|Salary
Bill|001|20000
John|002|30000
Steve|003|35000
] (delimiter is '|');
Citizens:
Load * inline [
Name|Address
Bill|New York
Mary|London
Steve|Chicago
Lucy|Paris
John|Miami
] (delimiter is '|');
EmployeeAddresses:
Load Name as Employee, Address Resident Citizens where Exists (Employee, Name);
Drop Tables Employees, Citizens;
|
Detta resulterar i en tabell med namnet EmployeeAddresses i datamodellen, som kan visas som ett tabelldiagram med hjälp av dimensionerna Employee och Address.
Satsen where: where Exists (Employee, Name) betyder att enbart namnen från tabellen Citizens som också finns i Employees laddas till den nya tabellen. Satsen Drop avlägsnar de tillfälliga tabellerna Employees och Citizens för att undvika sammanblandning.
|
Employee |
Address |
Bill |
New York |
John |
Miami |
Steve |
Chicago |
|
|
Ersätter satsen i exempeldata i det föregående exemplet som bygger tabellen EmployeeAddresses med följande, med hjälp av where not Exists.
NonEmployee:
Load Name as Employee, Address Resident Citizens where not Exists (Employee, Name);
|
Satsen where innehåller not: where not Exists (Employee, Name), betyder att enbart namnen från tabellen Citizens som inte finns i Employees laddas in i den nya tabellen.
|
Employee |
Address |
Mary |
London |
Lucy |
Paris |
|