I have a MySql query which I would like to pivot dynamically, with Company names as column headers and the company financial fields as row headers. Currently I have this: which gives me this: Company TotalRevenue Overhead TotalJobCosts GrossProfit Chicago’s Best Construction 2098001 363750 1424420 67358…
Tag: mysql
How to import data from one table to another – SpringBoot JPA /MySQL
I recently created a vehicle management system The system is derived from MySQL database and server side in spring I want to create another table (automatically at runtime) that will display only 2 of the columns of the existing table. And the question is what am I doing wrong? Final goal – when adding …
How do I check if a column have more than two items and if it have than do the avg() on it in SQL?
I have 4 tables The user and item from buys and rates are foreign keys. I can`t figure out how to put a condition to take out the items which have only one rating and do the average only on the ones who have 2 or more ratings. This is the question in the exercises (For each item that has
get aggregation values by other values in sql
I have two tables that looks like this in their schema : create table PRODUCT_NOMENCLATURE(product_id integer, product_type varchar(100), product_name varchar(100)); insert into PRODUCT_NOMENCLATURE(…
How does page overflow with columns (InnoDB) work in MySQL?
The documentation says: “Whether columns are stored off-page depends on the page size and the total size of the row.” 1.- This means that if I have a page size of 16KB, the maximum size of the row would be 8KB, therefore, if I have 4 columns, will the maximum size of each column be 2KB (approximat…
How do I write SQL query for the website traffic
I have a table record with the columns: How do I write a query that will list the site traffic per month (measured in # of logins) from January 2017 through December 2017 Answer You can use group by as follows:
MySQL: Updating multiple columns using if else
I need help to set a mySQL update query for my little project like below: In my table, there is a column REFERENCE which contains varchar like where the character before the symbol ‘_’ determines certain values for other columns like stated above. I am still fairly new to mySQL, so appreciates any…
Mysql if Null or Empty String then Show N/A
Hello I’m new to mysqsl and I’m trying to display N/A if the return data is empty or NULL but my query is unrecognized statement type. What do you think is wrong with my query? wrong placement of code? END Answer Use IF with ISNULL here: If you really wanted to use a CASE expression, then it would…
How to re-use result from a SELECT statement?
My goal is to re-use the result from a SELECT statement to be used in SQL EXISTS statement. The general idea looks like this: The actual SQL statement I am trying to reduce: Answer This query: Doesn’t really make sense. It is saying to return all rows if col = 1 is in the table — but then it filte…
Find rows that have characters other than a plus (+) sign or number in a phone field
I want to find all rows in a phone column that have any character other than a plus sign (+) or numeric digit. It can be any character like slash, space, bracket, alphabet or any other character. The column has phone numbers, but may rows has space, brackets and slashes. I want to see those. Like: But theses …