I have the a sql table payments with the following columns: id|name|amount|reference_number|payment_date|status And here is some values 1|John Doe|10.00|123456G|2019-02-21 08:00:21|confirmed 2|John …
Tag: mysql
MySQL: How to track a players total kills throughout his career
I have a table structure with 4 essential columns: match_id date player_id kills (of a player in the current game) The table will have data for many different player_ids, and what I want to …
MySQL FullText in Boolean mode: searching keywords that contain ‘+’ as part of the string
I have looked at dozen ‘similar’ questions, without luck. I understand that + attached to a keyword in FULLTEXT in BOOLEAN mode has a special meaning, however, what if our keyword(s) actually contain +…
SQL count rows with same value in column and group by id?
i have a table like this: i wonder if its possible to count the rows with same value and group them by id , but every time the code will return count 1 if i group them by id and not by value wanted output: Answer You need to count the value of the column value for each id: See
Add column moving average in mysql
I am currently adding crypto market data to my mysql database. I have the following data per minute : I would like to add the simple moving average of different time periods to the mysql database. I tried to do this calculation in python but this took to much time. Therefore, I calculated the SMA of a 50 day …
How to make my WHERE clause not run a syntax error in SQL?
The questions asks, “Write a query to display the customer name and the number of payments they have made where the amount on the check is greater than their average payment amount. Order the …
How to create unique key base on three field?
I have two foreign keys in table: userId visitorId Also field action I want to add constraints on these three field, that userId + visitorId + action will be unique. How to do that in Workbench, …
SQL: Using SORT to group same values together while mixing different values randomly
Let’s say I have a table Songs(title,songwriter). I want to get a list of songs where songs of the same songwriter appear in one block. So i just sorted: SELECT * FROM Songs ORDER BY songwriter ASC …
Relationships midst two tables?
I have table visitors and table users. Each visitor can be created by only one user and contains field visitors.userId. So, any another user from table users can edit or delete one or more visitors. …
SQL query to fetch unique entries. Is the query correct and efficient?
The table structure is provided below. query used, desc p2p Output ‘auto_id’,’bigint(20)’,’NO’,’PRI’,NULL,’auto_increment’ ‘created_at’,’datetime’,’NO’,”,NULL,” ‘expiry_date’,’datetime…