How to use custom SQL select statement in excel

%3CLINGO-SUB%20id%3D%22lingo-sub-364724%22%20slang%3D%22en-US%22%3EHow%20to%20use%20custom%20SQL%20select%20statement%20in%20excel%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-364724%22%20slang%3D%22en-US%22%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHi%20everyone%2C%20I%20have%20an%20Excel%20workbook%20in%20which%20i%20have%203%20queries%20that%20I%20have%20imported%20using%20the%20%22Get%20data%20from%20Table%2FTable%22%20function.%20I%20need%20to%20use%20a%20select%20statement%20to%20retrieve%20certain%20information%20from%20the%203%20different%20tables%20in%20the%20workbook%20using%20joins%20in%20the%20select%20statement.%20Please%20see%20below%20SQL%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%22SELECT%20top%2010000%20%5BT.PrImaryIP%5D%2C%20%5BPT.KB%5D%20%2C%20%5BPT.CVE%5D%2C%20%5BPT.Date%5D%2C%20%5BT.ComputerName%5D%2C%20%5BS.Status%5D%3C%2FP%3E%3CP%3Efrom%20%5BTemplate%24%5D%20AS%20%5BT%5D%2C%20%5BServers%20List%24%5D%20AS%20%5BS%5D%3C%2FP%3E%3CP%3Eleft%20outer%20join%20%5BPatch%20Data%24%5D%20as%20%5BPT%5D%20on%20PT.KB%20%3D%20T.KBID%20and%3C%2FP%3E%3CP%3Eleft%20outer%20join%20%5BServers%20List%24%5D%20AS%20%5BS%5D%20on%20S.IPAddress%20%3D%20T.PrimaryIP%22%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EMy%20problem%20is%20that%20I%20do%20not%20know%20where%20to%20place%20the%20query%2C%20I%20tried%20using%20the%20Advenced%20Editor%20but%20it%20does%20not%20bring%20back%20the%20results.%20Can%20anyone%20please%20help%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-364724%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EDeveloper%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EExcel%20Online%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMacros%20and%20VBA%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EOffice%20365%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-364780%22%20slang%3D%22en-US%22%3ERe%3A%20How%20to%20use%20custom%20SQL%20select%20statement%20in%20excel%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-364780%22%20slang%3D%22en-US%22%3E%3CP%3EYou%20may%20embed%20SQL%20query%20only%20within%20connection%20to%20SQL%20database.%20If%20you%20query%20the%20tables%20from%20the%20Excel%20sheet%20use%20Merge%20Queries%2C%20Filter%2C%20etc%20in%20Power%20Query%20Editor%20menu%20(and%2For%20M-Script%20code%20if%20you%20are%20familiar%20with%20it).%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Occasional Visitor

 

Hi everyone, I have an Excel workbook in which i have 3 queries that I have imported using the "Get data from Table/Table" function. I need to use a select statement to retrieve certain information from the 3 different tables in the workbook using joins in the select statement. Please see below SQL,

 

"SELECT top 10000 [T.PrImaryIP], [PT.KB] , [PT.CVE], [PT.Date], [T.ComputerName], [S.Status]

from [Template$] AS [T], [Servers List$] AS [S]

left outer join [Patch Data$] as [PT] on PT.KB = T.KBID and

left outer join [Servers List$] AS [S] on S.IPAddress = T.PrimaryIP"

 

My problem is that I do not know where to place the query, I tried using the Advenced Editor but it does not bring back the results. Can anyone please help

1 Reply
Highlighted

You may embed SQL query only within connection to SQL database. If you query the tables from the Excel sheet use Merge Queries, Filter, etc in Power Query Editor menu (and/or M-Script code if you are familiar with it).