Input data id year Name provid prov 1 1995 MAC 1995-11_CL236 reg 236 1 1995 MAC 1995-11_CL230 reg 230 (1) 1 1995 MAC 1995-11_CL229J reg 229J 1 1995 MAC 1995-11_CL260 …
Tag: sql
String or binary data would be truncated when using it in a stored procedure
I create this TYPE table in database: CREATE TYPE [dbo].[AccessLevel] AS TABLE ( [RoleId] [INT] NULL, [Access] [NVARCHAR](1) NULL, [IsDelete] [BIT] NULL ) GO and I need to insert …
How to retrieve SQL Error message with Hibernate
I have developed a small application accessing a PostgreSQL database with Hibernate. When I try to delete a record involved in a foreign key with another table, a javax.persistence….
How to get the count of 2 values in the same column, in the same table?
I have a dataset about chess games, and in the winner column there are only 2 values: ‘white’ and ‘black’. I want to show COUNT(winner) as WHITE_WINS and COUNT(winner) as BLACK_WINS. I tried inner joining the table by itself, however couldn’t get the correct SQL query to do the j…
Arranging data by year and proportion
I have one table with the following format: Note 1: [End_Date = NULL] means that participation has not ended. [Proportion = NULL] means that participation is 0. Output: I want to have the proportion of each sub_entity for every active year. Note 2: One Sub_Entity can be a proportion of different Entities. The…
Teradata SQL getting last not null value
I have a table in Teradata that looks like this: Account_Num Install_Due_Dt Install_Num Install_Pay_Dt 12805196 12/08/2019 1 12/08/2019 12805196 10/09/2019 2 …
High performance query to get datetime when value was last changed
The data I am working with Consider the following 2 database tables: CREATE TABLE [dbo].[Contact]( [ID] [int] IDENTITY(1,1) NOT NULL, [Contact_UID] [uniqueidentifier] NOT NULL CONSTRAINT […
IntelliJ IDEA does not recognise specific database schema in Javascript/Typescript files
At some point I was amazed when I managed to set the support of specific schema in my nodejs modules. Unfortunately, later IntelliJ IDEA decided to crash and I needed to remove my .idea folder, thus I lost all of my configurations. So, the problem is that when I write SQL queries it does not find tables or fu…
MAX Date for each row
I am having some difficulty at writing a syntax that will provide me with the most recent date for several results. Little bit of background, I am pulling live data from an IBM AS400, I have no SQL tables, I am connecting to the tables via ODBC, using QTODBC to create my queries, then I export them to Power B…
SQL Updated question conditional division
Given columns A and B from Table1: Given columns S, M, L from Table2: I want to create a new column in Table1 that outputs the quotients of values of column B and Avg(Table2.S) only if the entry in the same row in column A of is ‘Small’. If column A has ‘Med’, we divide by Avg(Table2.M…