Skip to content

Tag: mysql

Remove specific value in a string with SQL or grafana

Displaying some data using free version of grafana. The string that has to be displayed looks like this: 5555.7777, but I only want to display 5555. Are there any functions to remove .7777 in SQL or grafana, so that the value that will be displayed only looks like this: 5555. Thanks in advance. Answer You sho…

GROUP CONCAT and LEFT OUTER JOIN to split

I’m working with SQL Workbench. This is an example of the tables I have: I have not created this DB and can’t modify it. Each building corresponds to a site, so it contains a KEY to such site. Same with levels and buildings. I am trying to get this result the first two columns are easy, but I&#821…

how to group the data by some interval datetimes?

there are many devices and while using it will upload data every some seconds or minutes. I want to get the sections of date-time that the device is in use can it be true that group the data by an interval? let us consider interval = 1 minutes then group the data which the minus of the two date-time is

MySQL table update after multi field check

Hi I have two table one like this one: table1 and one like this: table2 I would like to update all the fields on the table2 column “newID” based on this rules: if (table2.ID = table1.ID_actual or table2.ID=table1.ID_old) then table2.newID = table1.newID How can I resolve this problem ? Answer You …

MySQL Trigger Nested Group_Concat Duplicates

I have a trigger to conditionally GROUP_CONCAT a few columns. I can remove duplicates from within a single column, but I’m struggling to remove duplicates between two or more columns. Current trigger (two column example): Fiddle: https://dbfiddle.uk/?rdbms=mysql_8.0&fiddle=46a6bb915fa7e2e9106b073677eee6cd…

MySQL – Query and group in a single row

I have a set of data as below: EmployeeId Salary_Basic Salary_Transport Year E001 12000 3000 2018 E002 9000 2000 2018 E001 13000 3200 2019 E002 10000 2400 2019 E003 15000 5000 2019 What I want is below: EmployeeID NetSalary_Year2018 NetSalary_Year2019 E001 15000 16200 E002 11000 12400 E003 0 20000 Can anyone …