Category "sql"

Could anyone help me with these two SQL queries on my Items table?

I made a SQL project for myself to learn. I am trying to answer these two questions: How many total items were sold between 1970 and 2000? What state in the US

I'm trying to get it to display but it is fetching me null when the output should be 'YES'

I'm trying to get it to display but it is fetching me null when the output should be 'YES' SELECT STRT_DT,END_DT,SYSDATE AS DT, CASE WHEN TO_CHAR(STRT_D

Update value using row index

Say I have a table like below with values I want to update in specific rows, but no primary key, I only know the index of the row I want to update. Is this poss

SQL to count the instance and total instances on sorted data

Is there an efficient way to add the Instance and Instances columns on sorted SQL? Some kind of self join? I quite often have to do something like this and loop

Function based trigger for audit table

I have 2 tables, one main table and one audit table. create sequence dbo.users_seq; create table dbo.users ( id bigint primary key default(next value for dbo.

Typo in decimal place + postgresql

I have a data set of students that calculates average scores (to the nearest decimal) as of a certain date.The data set is riddled with typos. A sample data is:

How to strip ending date from string using Regex? - SQL

I want to format the strings in a table column, in a specific format. Input table: file_paths my-file-path/wefw/wefw/2022-03-20 my-file-path/wefw/2022-01-02 my-

Hibernate keeps creating N+1 querys

I've got no idea why is this happening. I thought the "JOIN FETCH" thing and/or "EntityGraph" were meant to address this, but then the query made by Hibernate l

How can I interrogate user activity in Laravel

I'm looking for a way to best analyse the user data in our app. for example how many users have read 0 articles on our site how many users have read 1 article o

Calculating Percentage Difference

I am looking to perform a query that will calculate the product revenue percentage difference from 2019 to 2020 for each state. Can anyone lead me in the right

Is it normal to lose 30 minutes of data on a SQL Server crash?

We have worked with Oracle for a number of years and we now need to develop a new application using SQL Server in AWS for the first time. What surprised us, is

SQL own Function with sum and avg

I tried to code A own function that adds the values (NumberStars) together and then calculates an average value from th NUmberStars. Numberstar is a value that

How to create a view in SQL?

I am new to databases and SQL and I am stuck with this problem. Any help would be apriciated. Thank you in advance. I have the following schema: The problem is

Insert intention lock causes deadlock with composite primary key

I would like to ask for help :) Two INSERT statements are issued simultaneously by 2 users into a doctrine-generated many-to-many table: INSERT INTO my_table (c

sum of recursive tree using Postgres?

I have a tree structure that looks like this: root A B A

Also display the model of computer allocated to the employee and the manager, how to do thi

Display id, name, manager id and manager name of those employees who are allocated a computer and whose manager is also allocated a computer. Also display the m

How to calculate difference in month in dbplyr (R and sql)

I tried to calculate the difference between dates in months for a huge database, using dbplyr package which sends my codes to the sql query. I tried different w

SQL join concat on inequality

I am struggling with query logic. I have two tables, e.g. Table1: A B 0 1 0 2 1 1 1 2 Table2: A B C 0 0 a 0 1 b 0 2 c 1 0 d 1 0 e 1 1 f 1 2 g I need to left

sql dynamic pivot where clause failing

I am trying to figure out where my query is failing on a where clause, I hope some of the local experts could point it out and explain why. Also I would like to

Writing SQL command to update a password in a part of a column

I am trying to write an sql command that enters a password inside a string. The database entry that I need changed is in the users table preferences column and