Skip to content

Tag: sql

phpmyadmin how can i create a event like this?

I am creating an event on one of my databases to check if the client changed a specific parameter called ‘serverlog’ which is a boolean on my Sql database. Is there a way to loop through all the users in a table called ‘users’, check if ‘serverlog’ is false and update/set a…

How to find the average time? SQL Server 2017

I have a request like this: I need to find the average time for each status. For example, add up the time of all statuses 2 and divide by their number. As a result, get something like 2 days 5 hours. How to fix my request to make belt operations possible? Answer Taking your limited example data, something lik…

Update in DB2 using where exists instead of join

I’m trying to perform an update in DB2, which I started out trying with an inner join, but DB2 won’t allow that. I altered it to use a ‘where exists’ clause but now it’s telling me that main_discount in my set clause is not found (I’m assuming because it isn’t referen…

Trying to exclude certain users

New to SQL but I’m trying to find titles wherein the words “blue” and “black” are present. However, they cannot be from users who have ids of 1 and 5. This is what I did: However, when I add that id 1 and id 5 shouldn’t be in the query, it shows me something like this: Blog…

Oracle partitioning by range

I need to split the table into partitions, namely into three partitions according to the EVENT_TIME field, where the first partition is an interval of a week from today, the second last week and the third partition is history, where data that does not pass into the first two partitions are placed. In addition…

How to add ” and , for multiple ID in SQL Server

I am writing a SELECT query that has multiple id, and I have to manually add ”,” (e.g ’12L’,’22C’). I have around 2000 id in an Excel sheet. Is there any quicker way to add ”,” to all the ID? Answer Here is a conceptual example for you. It will work in SQL Serve…