Need SQL Code Changed To Python Code Equivalent

Need SQL Code Changed To Python Code Equivalent
0

Hi There,

I have the following SQL Code :-

SELECT * INTO #Temp4
FROM
(
SELECT
tt5.[Venue],
tt5.[BID],
MIN(tt1.[Date]) AS [Date],
tt5.[Display / Flypast],
SUM(tt1.[Duration]) AS [Duration (mins)],
(SELECT DISTINCT '; ' + t5.[Aircraft Combined]
	FROM #Temp5 t5
	WHERE tt5.[Venue] = t5.[Venue]
	AND tt5.[BID] = t5.[BID]
	AND tt5.[Display / Flypast] = t5.[Display / Flypast]
	FOR XML PATH ('')) [Aircraft Combined],
SUM(tt5.[Dakota and Fighters in Same Slot?]) AS [Dakota and Fighters in Same Slot?]

Could someone please tell me, what the Python Code equivalent would be ?

Any help and info would be much appreciated.

Regards

Eddie Winch

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.

Note: Backticks are not single quotes.

Not really sure what you are asking, because they are completely different languages. You write an SQL query against a database. You can use Python to make a call to the database with the query, but there would be no Python equivalent of the query (at least not to my knowledge).

Wow, those column names. Horrifying.

Hi Randall, many thanks for your reply.

I actually have a Python Code, using Pandas in Jupyter Notebook, getting a DataFrame from an. xls Excel File. but I have hit an issue, with the Code.

I have a friend who, is good with SQL Code, and he is trying to, to help me by writing Code in SQL, to do what I want. That particular part of the current Code, is significant to the issue I have. Could I post the full Python Code here ?

The issue I am talking about is covered in the following Link, on page 3 Of that Thread :-

Regards

Eddie Winch

I promise you that you don’t have to use them.

Have a look at this Medium article and see if it helps you resolve your issue.

Hi Alice,

Many thanks for your reply, yes I will take a look at that article, thanks for posting it.