Hello All,
Firstly am relatively new to this SQL and learning step by step.
Well, am trying to mimic an Excel function into a SQL query, which has a nested sub query.
Example:
Table1
Name || ID
XYZ || 12
ABC || 13
VDS || 14
Table2
Bank_Approved || ID || Certified
NULL || 12 || No Value
1234 || 13 || No Value
1245 || 14 || Yes
Here, Table1 has Name and ID which is linked to the Table2 using Inner JOIN.
Now, i need the resultant Table as follows:
Table3
Name || Bank_Cert
VDS || 1
The
Bank_Cert result should be "
1" since
Bank Approved has "
1245" and it is
Certified.
Excel Function:
COUNTIFS('Table View 1'!BX:BX, ">0", 'Table View 1'!C:C,C5, 'Table View 1'!CG:CG, "Yes")
What I have tried:
(SELECT Count(case when [Bank_Approved] IS NOT NULL then 1 end)FROM Table2 WHERE [Certified] = 'Yes' group by Table1.[Name] ) as Bank_Cert
Error: Each GROUP BY expression must contain at least one column that is not an outer reference.