-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsqlite_groups.py
More file actions
35 lines (27 loc) Β· 1.07 KB
/
Copy pathsqlite_groups.py
File metadata and controls
35 lines (27 loc) Β· 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import sqlite3
def run_database_grouping_analysis():
print("π Starting Sudhir's Advanced SQL Grouping Script...\n")
db_name = "sudhir_projects.db"
conn = sqlite3.connect(db_name)
cursor = conn.cursor()
try:
# MAGIC SQL QUERY: Create groups based on status and get the total budget and number of jobs
query = '''
SELECT status, COUNT(*), SUM(budget)
FROM upwork_jobs
GROUP BY status
'''
cursor.execute(query)
rows = cursor.fetchall()
print("π Real-Time Financial Breakdown by Status:")
print("-" * 65)
for row in rows:
print(f"π Status: {row[0]:<15} | π’ Total Jobs: {row[1]} | π° Combined Budget: ${row[2]:,.2f}")
print("-" * 65)
print("\nπ SQL Group By analysis completed successfully with 100% data integrity!")
except Exception as e:
print(f"β Grouping Error: {e}")
finally:
conn.close()
if __name__ == "__main__":
run_database_grouping_analysis()