Skip to content

Commit 7ec4a63

Browse files
committed
SQL query added
1 parent a2fd045 commit 7ec4a63

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

Dataframe_SQL_query.ipynb

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@
208208
"cell_type": "markdown",
209209
"metadata": {},
210210
"source": [
211-
"### Run a slightly more complex query\n",
211+
"### Run slightly more complex queries\n",
212212
"How many entries in the `Close` field are higher than 500?"
213213
]
214214
},
@@ -234,6 +234,35 @@
234234
"count_greater_500 = spark1.sql(\"SELECT COUNT(Close) FROM stock WHERE Close > 500\").show()"
235235
]
236236
},
237+
{
238+
"cell_type": "markdown",
239+
"metadata": {},
240+
"source": [
241+
"What is the average `Open` values of all the entries where `Volume` is either greater than 120 million or less than 110 million?"
242+
]
243+
},
244+
{
245+
"cell_type": "code",
246+
"execution_count": 36,
247+
"metadata": {},
248+
"outputs": [
249+
{
250+
"name": "stdout",
251+
"output_type": "stream",
252+
"text": [
253+
"+------------------+\n",
254+
"| avg(Open)|\n",
255+
"+------------------+\n",
256+
"|309.12406365290224|\n",
257+
"+------------------+\n",
258+
"\n"
259+
]
260+
}
261+
],
262+
"source": [
263+
"avg_1 = spark1.sql(\"SELECT AVG(Open) FROM stock WHERE Volume > 120000000 OR Volume < 110000000\").show()"
264+
]
265+
},
237266
{
238267
"cell_type": "markdown",
239268
"metadata": {},

0 commit comments

Comments
 (0)