Skip to content

Multiple SUM’s in a SELECT but on one view

I’ve written a select statement to assist with timesheet approval. It show’s the summation of hours entered against a user based on different roles booked, i.e. Standard Office Hours, Overtime, Holiday & Offshore. I want a single row per [Name] but I get a row for every SUM where the user has …

Insert records into one table using key from another table

I have a table with year, start and end columns like below. It has several years in it. Do not ask me why there is a year called 4 in there because I could not tell you. I just know that it cannot be removed from the table or else the web application will break. I use this query to

RANK data by value in the column

I’d like to divide the data into separate groups (chunks) based on the value in the column. If the value increase above certain threshold, the value in the “group” should increase by 1. This would be easy to achieve in MySQL, by doing CASE WHEN @val > 30 THEN @row_no + 1 ELSE @row_no END …

Common Data Type in Oracle for reusability

I have data type with fixed column data type and size. For example, If you see above I have CREATE_USER char(36) in almost all tables. I want to make it replaceable. So that in future I can change the type/size. For example, I call it CREATE_USER myDataType, so that in future I need to replace it only one pla…

Is there a wait method for Google BigQuery SQL

I’m scheduling a query to run every day that picks up data from a table that get’s written to Google BigQuery automatically. Usually the table is there, but I’d like to be sure before I execute the query depending on this table. I’m looking into other ways as well, but the simplest way…