Skip to content

Tag: sql

How do I reset a MySQL column in a table every year?

I have a column named lv_casual in a table called tbl_employees. I need to reset the column to 0 at a specific date every year. Answer You can use MySQL event schedule. Providing an example below. You have to enable the schedular first Then create the event Check MySQL document for creating event

MySQL Joining multiple tables with where clause result is too slow

Let’s say I have the following structure of tables; and I want a result of; So I used the following query; I still have other tables that are connected to table1. The problem is the result is too slow even though there are only three results. I’m not that good at databases maybe I’m doing it…

Getting not valid month in Oracle sql

I have a table called Transactions that has a column called trans_date. I am just trying to do a simple query in the SQL*Plus command window The query is When I run this query I get not valid month and there is a little * under trans_date. Most of what I have read suggests the query is right but I

Missing IN or OUT parameter in Oracle SQL

Im getting an error on this parte of SQL{ “U” = UPPER(:codigo) }. When i remove the variable and hardcode :codigo as u or U it works fine. The erro i receive is Missing In or Out parameter. I’m receiving this error on Oracle 12c Service Bus Full SQL: Answer The problem was: Each time variabl…

SQL Server: Counts and Percentage by Group

I’ve tried the suggestions I’ve found on SO and cannot get the results I’m looking for which is this: I am able to get the first two columns with this code: — What I’ve tried: Trying to use a calcuation in a subquery to represent the total number of rows in the table is beyond me…

SQL Row Data to Column Data in Join

Trying to wrap my tiny brain around how to write this query and I am at a loss: Current: How I would like it to look: If someone can point me to a function that could help me with this, it would be much appreciated. I already tried using: max(case when ….) and pivot() which I found in other articles,

SQL how can i detect if a value decrease over time?

Hi, how can i check who are the employees whose salary has fallen ? : I only want to fetch the name of employees whose salary has fallen Answer You can use the positional analytic function LAG() to find these rows. This is a standard SQL function that peeks at a previous row, according to a specific criteria.…

Delete node when child have a certain value is found

I intend to remove a node whenever I find the unit_qty tag with the value equal to 0.0000. For example considering that the message below is called MESSAGE_DATA: the purpose of message_data is to return the following: I’ve already tried the following options: I don’t know if I’m looking up t…