Skip to main content

All Questions

Tagged with
1 vote
3 answers
45 views

Combine 2 SELECTS in one result Side By Side

I have 2 selects that just get the SUM of IDs and are grouped by month.. I would like to have them only on 1 SELECT - side by side... SELECT MONTH(data) AS month, COUNT(id) AS TOTAL FROM numeracao ...
Eduardo Luís's user avatar
0 votes
0 answers
109 views

Creating aggregated column in SQL with values depending on previous row - MySQL 5

I would like to get some help on the following query: I have the following data frame I created with python pandas: data = pd.DataFrame({'user_id':[1,1,1,2,2],'event':[1,0,1,1,0]}) The output is: ...
GDC's user avatar
  • 17
0 votes
3 answers
294 views

Sort records based on string

Please consider the table below Id F1 F2 --------------------------- 1 Nima a 2 Eli a 3 Arian a 4 Ava ...
Syed Saqlain's user avatar
0 votes
1 answer
1k views

MySQL 5.7 recursive query on hierarchy data with unknown levels

I am developing a hierarchy data structure where I want to perform a recursion to get the desired output id role_id reporting_to ------+-------------+----------------- 1 100 ...
M14's user avatar
  • 1,810
0 votes
2 answers
280 views

MYSQL View Query Performance Issue

I have 5 SQL tables store staff departments sold_items staff_rating I created a view that JOINs this four of the tables together. The last table (staff_rating),I want to get the rating column at a ...
urchmaney's user avatar
  • 618
0 votes
2 answers
108 views

MYSQL 5: Returning expression if statement is false, similar to NULLIF

I have a long complicated expression that refers to multiple tables. The expression returns a string, but i want to return a different string if the returned string was empty "". With the IF ...
Malthe's user avatar
  • 75
1 vote
2 answers
3k views

why mysql does not reclaim free space in ibd file?

I am using mysql5, and I want to shrink some 'deleted' spaces in ibd file. I already search for 'optimize table' option, but I cannot use it now, because it is a very critical table. It uses 19G in ...
Hyeongwoo Park's user avatar
-2 votes
3 answers
183 views

MySQL ORDER BY field with a toggle

I have a mysql result that looks like this: | compare | field1 | field2 | much more | ----------------------------------------- | new | x1 | y | ... | | old | x1 | y | ...
Paladin's user avatar
  • 1,637
1 vote
1 answer
1k views

Same query returns different values on repeated execution

Database in use: 5.6 (I can't use LAG function which is from mysql 8) I have the following table structure in mysql book_id | Version | Rating | Price varchar(25) | Decimal(10,2)| int | ...
Abhijith Nagaraja's user avatar
0 votes
1 answer
452 views

powerdesigner how to generate sql using `backquote`

Sybase PowerDesigner Version 16.0.0.3514 Current DBMS mysql 5.0 Generate SQL In fact, I want to add backquote around the field name, like this How to configure it?
iuha's user avatar
  • 1
1 vote
4 answers
4k views

Checking column exists with If else condition in sql

I'm trying to check weather thw column exists or not IF (SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'tb_consumer' AND COLUMN_NAME='businness_id' > 0 ) THEN PRINT 'test' ...
Suresh Atta's user avatar
0 votes
2 answers
67 views

User-Defined Session variables using in IN() function returns unexpected result

For example I have a table named TABLE and it has a single field named FIELD with values 1 and 2. Running this statement SELECT GROUP_CONCAT(`FIELD`) INTO @LIST FROM `TABLE`; and SELECT @LIST; ...
reggie's user avatar
  • 626
0 votes
1 answer
2k views

Get all childs by parent id using JOIN

I have a table representing the family tree. It has fields ID, NAME, LEVEL, PARENT_ID. And the column PARENT_ID is the foreign key and refers to column ID of this table. How can I get a list of ...
Mike Brown's user avatar
0 votes
2 answers
120 views

Select result of the subquery

I am trying to select the q1.res which would be the result of the FROM subquery: (SELECT SUM(gwr.res1)/(COUNT(*)*1000) as 'res' FROM process.gwr WHERE started = 1 AND gwr.user2 = g....
Lucas's user avatar
  • 3,735
-1 votes
1 answer
578 views

Error 1064(42000) Creating a Table in msql5

CREATE TABLE Message( MessageID int unsigned not null auto_increment primary key, naiveUserID int unsigned(7) NOT NULL, Title varchar(20), bodyOfText TEXT(2000) ); I keep trying to run ...
user3020163's user avatar

15 30 50 per page