I’m trying in every way to create a database and populate it with sql script from the command line. mysql –user=root –password=hello –execute=create database test –source=’accounts.sql’ -> …
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 0 and
Converting column data into row in pl/sql
Hi When i went for an interview they asked me this question. Create table course(Name CHAR(10)); insert into course values (‘Java’); insert into course values (‘Oracle’); insert …
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 will be : 1*X1
displaying values from sql in html select option not displaying values
i have created a html form using php and sql. The form contains a field called spaces which is a select dropdown. The values are coming from an array which i declared in php. If the values in array …
How to search incasesensitive query in the Postgresql database using Laravel query builder?
I want to create a filter. But I am facing case-sensitive problem. I have tried with my below code. But It didn’t work. I have got error ‘call undfiend lcase’. $type = strtolower($type); $name = …
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, “free_day”: 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 …