Skip to content

Tag: sql

Return false if no rows for select

I have next query: It works fine, if we have some records in new_date table, but if it is empty for some user, query just returns empty string. How I can return false, if there are no records also? Answer You could just selects an EXISTS expression here: This would always return just a single record, containi…

Find the remainder of the number in a new column in SELECT statement

I am building a program in which the user enters a value, either negative or positive, and this value is added to the table, and through the SELECT statement, those values are stored and the remaining values are found in a new column, and at each entry, the data of the DataGridView is updated. Example: Date N…

Oracle SQL: ORA-01858 error on date fields

I have many tables with a date in their name. For example MY_TABLE_2021_06_01, MY_TABLE_2021_06_02, etc. I’m trying to extract the date from the table name and see if any tables are more than an year old. This is my code: The above code works fine if I don’t include the where clause where table_da…

The difference between OUT and OUTPUT

In an application that uses SQL Server I came across a code that uses both OUT and OUTPUT parameters. What is the difference between OUT and OUTPUT parameters. Answer As noted in the comments, the 2 are synonyms. From the documentation the syntax for the clause is listed as below: So this denotes that either …

Populating scd type 2 kind of dates for active inactive input data

I saw this question in one of the interviewing practice platforms and initially assumed its a gaps and islands problem, but I couldn’t go ahead with that logic. In ETL tool called Abinitio, there is a function called key_change using which we can solve these kind of problems. But, I am unable to do it i…