Skip to content

Tag: mysql

Wrong data output on basic select condition

i’m trying to get the values which Dates bigger then 2021-07-17 and Cities starting with ‘G’. I have id in the PERSON table, id (references from PERSON(id)) and date in VACCDATA table, id (references from PERSON(id)) and city in ADDRESS table. While i only want the Row 2 (because it’s …

How to count and order correctly result from table

I have like this task currently: (sql fiddle: http://sqlfiddle.com/#!9/431723/49/0) It is necessary to form a SQL query to the files table which displays the number of files based on the success of the conversion and the presence of a good rating from registered / unregistered users. Output format: user_type …

SQL Query for grouping within a segment with a condition

We need to select all the columns. Condition: Within a single MAT+PLANT If any vendor crosses 80% we take records of that vendor only and reject other records within that MAT+PLANT. If within a single MAT+PLANT If all the vendors have below 80%, we consider all the records. As shown in the image: Have attache…

Find floating-point numbers

I have a table Balance with a column Coins of double type in my MySql database. However, in fact, I store int values there. So, I want to change the type from double to int. But before, I want to be 100% sure that there are no floating-point numbers in this column. What kind of SQL request should I write

Given a list, how to get the count from mysql table?

Given a string list, I want to get the count of each item from the table. However, I don’t know how to get the count(0) of item which does not exist in the table. for example, I have a table as follow. Given a list [“aaa”, “bbb”, “ccc”] , I hope a query can return me …

MySQL keyword aliases

I would like to set up aliases for MySQL keywords for faster typing of repetitive (or any, really) queries. Example: -> becomes: How could I go about achieving the above? I have looked around but unfortunately, most searches point to column and table aliases and I did not see a mention in MySQL documentati…