Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I have a sql query that displays a table of names and other columns I want to load an excel file that contains the list of names to exclude.
exemple of query :
name | age | date
david |26 | 1996
Alain | 29 | 1985
Pierre| 54 | 1977
exemple of excel file :
name | age | date
david |26 | 1996
so the result will be :
sql query - excel file
name | age | date
Alain | 29 | 1985
Pierre| 54 | 1977
how can i do this
Hi @taz803
Please try the below.
OriginalData:
LOAD
name,
age,
date FROM YourTable; -- Replace "YourTable" with the actual table name in your SQL database
The "Left Keep" function keeps only the records from the "OriginalData" table where the names exist in the "ExclusionList" table, effectively excluding the names present in the Excel file.
i tried you solution but i'm blocked here :
OriginalData:
LOAD
name,
age,
date FROM YourTable; -- Replace "YourTable" with the actual table name in your SQL database
my request it contient 13 colonnes and its a join request from 3 tables
Hi @taz803, Something like this.
Excel:
LOAD Capitalize(Trim(Name)) as NamesToExclude,
Age,
Date
FROM XYZ;
SQL:
LOAD *
Where not Exists(NamesToExclude,Capitalize(Trim(Name)));
SQL SELECT
FROM dbo.ABC
"Name",
"Age",
"Date"
FROM dbo.ABC;
DROP Table Excel;
Hi @taz803
Please try this
ExcludeNames:
LOAD name
FROM [lib://PathToYourExcelFile/ExcludeNames.xlsx]
(ooxml, embedded labels, table is Sheet1);
SourceData:
LOAD
name,
age,
date
SQL SELECT
name,
age,
date
FROM YourDatabase.YourTable;
FinalData:
LOAD name, age, date
RESIDENT SourceData
LEFT JOIN (ExcludeNames)
LOAD name
RESIDENT ExcludeNames
WHERE IsNull(name);
DROP TABLE ExcludeNames;
DROP TABLE SourceData;