9
I would like a help in extracting information from another spreadsheet through SQL.
The spreadsheet link where you will establish the connection and extract the information is this: By Google Drive
The spreadsheet link where is the Database, where contains the information for the extract is this: By Google Drive
I have a spreadsheet where you have the fields: Nº Tel, Reason for Sending, Activation Date, Import Date Change Date, Status.
I need to import all of them, with some criteria (except):
Nº Tel that does not happen again and is with the Status (RELEASED) does not need to be imported.
Nº Tel that does not happen again and is with the Status (TIME ANOMALY, PENDING, UNDER REVIEW) NEEDS TO BE IMPORTED.
Status does not need to be imported (DEFINITIVE ANOMALY)
Nº Tel which is repeated and has no Status (TIME ANOMALY, PENDING, UNDER REVIEW) NEEDS TO BE IMPORTED.
NEVER MIND the Nº Tel (phone numbers) that repeat IF has in any of them the Status LIBERATED, that is if you have 4 numbers repeated for example, and in one of them appears the RELEASED Status none of these numbers will be imported.
I tried in many ways but unsuccessfully, I’m still a beginner with SQL, I made the code below but it does not follow the rules mentioned above.
StrSql = "SELECT [Nº Tel], [Motivo de Envio], [Data Ativação], [Data Importação], [Data Alteração], Status FROM [export$] WHERE Status in ('ANOMALIA TEMPORÁRIA','PENDENTE','EM ANÁLISE')"
Excellent my friend worked perfectly, only that I am beginner with Database, you could explain me every line you wrote and describe what each thing does, because I do not like to only copy and paste, but rather understand what was done :D
– Magno
So I recommend you get a T-SQL book. Or take this course free in the mva
– Umo
But the explanation is how it is in the same answer. Only the phones will be included when the subquery does not find anything, so the
NOT EXISTS
. And I make the logical subquery merge withexport.[Nº Tel] = aux.[Nº Tel]
. Since the two are in the same table, I call the table in the subquery ofaux
.– Umo
Friend, you had helped me last time, only now it’s a new process to realize the filters, could you help me? the new rules are those: rules here the database remains the same: data here If you can help me thank you!
– Magno