Skip to content

Tag: sql

Teradata merge multiple records into single record

I want to merge multiple record into single record Ex: Input pdt status start_dt end_dt a Inactive 2022/02/02 2022/02/04 a Inctive 2022/02/05 2022/02/10 a Active 2022/02/10 2022/02/12 b Active 2022/03/13 2022/03/17 Output pdt status start_dt end_dt a Active 2022/02/02 2022/02/12 b Active 2022/03/13 2022/03/17…

How to avoid showing duplicate rows because conditions

The problem is where name_1 writes something to name_2 and name_2 writes something to name_1 there is a duplicate and as one result because I SELECT name_1, name_2 with condition How is it possible to show results with no duplicate rows, I only want to know if there is communication between user_1 and user_2 …

This Oracle SQL SELECT shouldn’t work. Why does it?

I am debugging a query in Oracle 19c that is trying to sort a SELECT DISTINCT result by a field not in the query. (Note: This is the wrong way to do it. Do not do this.) This query is trying to return a unique list of customer names sorted with the most recent sale date first. It returns an

Unpivot Access Data Table

Good afternoon, I would like to unpivot an Access Table. I have almost one hundred of columns in Access and one column with the ID and I would like to unpivot, considering all the columns except de ID into one column called “type” (for example). How could I get it from Access? It doesnt matter if …

SQL Conditional Print Statement

I am working on two different tables: sales and inventory. From the table inventory, there’s Quantity_Received and from the table sales, there’s Quantity_Sold. Quantity Remaining in Store represents the difference between Quantity_Received and Quantity_Sold. When the Quantity Remaining in Store is…

max DISTINCT returns multiple rows

I am working on an sql script which is executed by a .bat daily and outputs a list of IDs, the date of access, and their level. While it returns what I want, mostly, I noticed that some of the outputted rows are duplicates. Could someone please help me modify my script so that it outputs only one date (the