Skip to content

Tag: sql

Python – Running a SQL in a loop based on column value

I am trying to build a SQL query that runs based on certain conditions (if a column is filled run Query 1 else Query 2 and so on) as shown below: I am trying to build something like the above but the number of fields as variable (fields like col_a and col_b) are 6 in number. Is there a way

Determining what index to create given a query?

Given a SQL query: How do you determine what index to write to improve the performance of the query? (Assuming every value to the right of the equal is calculated at runtime) Is there a built in command SQL command to suggest the proper index? To me, it gets confusing when there’s multiple JOINS that us…

SQL Query calculating two additional columns

I have a table which gets populated daily with database size. I need to modify the query where I can calculate daily growth and weekly growth. Current Output I would like to add two additional columns which would be Daily Growth (DB_SIZE sysdate – DB_SIZE (sysdate -1)) Weekly Growth (DB_SIZE sysdate &#8…