Skip to content

Tag: oracle

Selecting multiple rows from the same table with common column?

Have the following hypothetical table User_Mail_Info in Oracle DB Primary key is User_Id,Mail_DL,DLId. There are other columns with the table as well. How to retrieve the UserId ,given the list of (Mail_DL and DL Id) ? Note: Mail_DL and DL_Id are not directly related. This is just hypothetical data For eg. In…

Oracle SQL randomising column entries

I have the below table: PC A MAXI PC1 A1 1 PC1 A2 2 PC1 A3 3 PC2 A1 1 PC2 A2 2 PC2 A3 3 Is there a way to generate ‘MAXI’ entries for each group of ‘PC’ and ‘A’ in a random order (or at least a seemingly even distribution, even if not random)? Desired output (count_pc would

Oracle SQL – Custom Sort

I have a scenario where I have following data: Table: Locations I want to sort in a way that all the IDs that end in ‘0000’ should be sorted first, then the TYPE ‘Warehouse’ and then the rest of the Stores. The desired output should be like How do I do this custom sorting? Answer This …

Sum value is too big when adding a another table ORACLE SQL

When I want to sum two values from two different tables – the tickets sold out on match and the TV transmission i got too big sum value in result. I figured out that for single match transmission cost is X times too big, where X is a number of tickets for this match, only when I join a tickets

Assignation counting up to maximum

I have the below 2 tables: aux1: PC A MAXI PC1 A1 1 PC1 A2 2 PC2 A1 1 PC2 A2 2 aux: VK D PC VK1 8 PC1 VK2 7 PC1 VK3 6 PC2 VK4 5 PC2 VK5 4 PC1 VK6 3 PC1 VK7 2 PC2 VK8 1 PC2 I would like to obtain the following output: VK D

Check if all values in a column falls into a specific group

I have the following table: and I want to check ALL values of the column ‘Token’ and return a flag string to designate what condition is met: when all records are in group (A, B) –> return ‘Condition1’, examples: when all records are in group (A, B, C) –> return &#821…