SQL - Taking the sum of two columns and then getting the average of each

SQL
Working on a problem and getting stuck on how to get the average once I've gotten the sum of two separate columns. What I can't seem to figure out is ...
3 years ago

Force an entire MySQL database to be in memory

SQL
For the purposes of running a large number of tests that interact with the database, I want to do two things: I would like to copy the schema of a d...
3 years ago

How to optimize the SubQuery that returns the same result for each outer select

SQL
I'm not expert SQL user so I'm seeing some advice to optimize the below SQL. SELECT pm.name, pm.WTPARTNUMBER FROM WTPARTMASTER pm, WTPART pt, CHECKO...
3 years ago

Enhancing performance when applying multiple joins in mysql

SQL
I have 3 tables: Nutritions_facts table which is static table that have all nutrition nutrition_id and nutrition_ename Products_info table which has ...
3 years ago

Length (column) greater than but spaces after the characters

SQL
I have this query to show all records where column is greater than 4 characters, however, the data contains spaces after the characters for example '1...
3 years ago

how to count number of words from multiple rows

SQL
here i am using split method to split a database row(it stores string value). i am using for loop to check each row . here how can i count total words...
3 years ago

Check for a substring in MySQL and return a value based on it

SQL
I have an SQL query that returns the following values: BC - Worces BC Bristol BC Central BC Torquay BC-Bath BC-Exeter BC-Payroll So, we have some B...
3 years ago

SQL Query Optimization for Cross Apply

SQL
Problem: Get the details of the last transaction for all customers who have had no transactions since 2015-06-30. Transactions not to be of type 2. I...
3 years ago

Merging two results from sql to echo on php

SQL
$result = mysql_query("SELECT * FROM election WHERE election_date >= NOW() ORDER BY election_date LIMIT 1"); $result2 = mysql_query("SELECT has_vot...
3 years ago

Spring Batch Paging with sortKeys and parameter values

SQL
I have a Spring Batch project running in Spring Boot that is working perfectly fine. For my reader I'm using JdbcPagingItemReader with a MySqlPagingQu...
3 years ago

Oracle display more than 24 hours

SQL
I have a table with two DATE columns END_TIME and START_TIME. On this table I run the following query: SELECT y.ID, TO_CHAR( TO_DATE('00:00:0...
3 years ago

Aggregate functions in query against view in Oracle

SQL
I am utilizing some aggregate in a query against a column PRICE in a view called ORDERS. Here how my ORDERS view was created CREATE VIEW ORDERS as S...
3 years ago

Struggling to UPDATE value in another table where all field of first table are certain value and first and other table share a field value

SQL
I have two tables. Table 1 has customer info Table 2 has booking info Table 1 has CustomerEmail as the primary key and table 2 has CustomerEmail as we...
3 years ago

PDO syntax or access violation error with pagination script

SQL
The code below works but if I type in some combinations such as index.php?page_no (wihtout a page #), or page_no=0 (zero that is, but page_no=1 and ev...
3 years ago

Move date from column1 to column 2 and column1 is set null

SQL
Any idea how to do this in MySQL? Current data: ID | name | lvl1 | lvl2 | lvl3 1 justin test Desired outcome: ID | name | lvl1 | lvl2 | lvl3...
3 years ago

MySQL after insert trigger get auto incremed value, update field value after insert gives "Unknown column" error

SQL
I am trying to figure out make a trigger to assign the value of the auto incremented 'ID' primary key field that is auto generated upon insert to anot...
3 years ago

left outer join in Oracle

SQL
I am implementing a left outer join with the customer table and am joining it with the payroll table. I am having trouble with Oracle recognizing that...
3 years ago

How do I Union two tables with different columns

SQL
I have Two Tables Called Table_A and Table_B like bellow. Table_A +-------+------------+------+---------+-----+ |MonthId|DepartmentId|Salary|Deducti...
3 years ago

Appointment App - AngularJS availability selection

SQL
I developed an application using Java Spring (backend api), mysql (DB) and Anguljar JS (frontend) that is designed to let users schedule an appointmen...
3 years ago

How do I Normalize this Auto Parts Database?

SQL
I am am new to PHP/Databases... But I am picking it up fairly swiftly. What I would like to ask you guys is pretty simple. I want to normalize my data...
3 years ago