In my database I have the following date-times: I want to be able to retrieve these records with the hours, minutes or seconds set to their 00 values: For example I want to be able to return records with seconds and milliseconds set to 00: Or return them setting the minutes to zero as well. How can I write a
Tag: sql
Regular Expression to extract string after seeing “number + one letter + [comma or whitespace]” in Bigquery
I am trying to extract: Abbey Grove Abbey Grove Abbey Road View Abbey Road Abbey Terrace Abbey Wood Road Abbey Grove from 23a, Abbey Grove 43a Abbey Grove Block 509a Abbey Road View 511 Abbey Road …
Conditional Order By in sql server with multiple order columns
i wish to perform conditional order by with multiple columns i am expecting a query like can we achieve this.? sample data result i need is Answer I think this is what you want: Appreciate that when price is NULL, the above reduces to: That is, the alternate CASE expressions just collapse to NULL, leaving the…
How to correctly execute this promise based SQL Query?
I’m using MySQL2 to connect my Node.js app with a MySQL Database. Unfortunately trying to perform some promise based prepared statements I just can’t get a proper function setup that either returns successfully after entering the record or to throw an error whenever something goes wrong. Any ideas…
Is there a shorter way to update a column with range values on Oracle SQL?
The update script will be like So that when I run the query below COLUMN_A has minimum value of 1 and maximum value of 10. Answer There is no “ranges” function in oracle, but you can emulate that using dbms_random which generates a value between 0 an 1. Multiply it by 10 so you get a value between…
Weighted Average of Survey Questions
I have to calculate weighted average for all questions. Assuming there are 22 questions in a survey which has 5 options as 1,2,3,4,5 and NA. For example, 3 people took the survey (all 22 question) Assuming there are 10 NA responses (combined for all 3). So, denominator will be : 22*3 – 10 = 56 Numerator…
Redshift Rounding Off Issue
I have a table which has a numeric(23,2) field that I need to divide to a constant. My baseline is this aggregation select site, sum(sales) / 1.07 as sales from sales group by site; But when I add …
How do I replace dynamic values?
In my PostgreSQL database I have such table: | employee | question | answer | |———-|——————————|————| | Bob | What is your favorite color?…
How to parse a json object – mysql
I have a json object like this: {“1”: {“penalty_percent”: 3, “free_day”: 5, “free_hours”: 24}, “2”: {“penalty_percent”: 2, “free_day”: 5, “free_hours”: 12}, “3”: {“penalty_percent”: 2, ̶…
Building table of unique sets
What I’m trying to do is build a table of unique sets of rows. What is the aim? I’m building an app for a service provider (let’s say cable company for example). Every customer has a set of …