Display the duplicate values once and list out any unique changes beneath each repeated value

I have a complex query that involves select distinct of multiple columns, joins, and where clause. However, the results are showing repeated values with different dates as follows:

ID  title   Date    other field
1   text 1  01-Jan-20   another value
1   text 1  07-Mar-20   another value
1   text 1  20-Sep-20   another value
1   text 1  30-Dec-20   another value
2   text 2  02-Feb-20   something else
2   text 2  12-Mar-20   something else
2   text 2  15-May-20   something else
2   text 2  17-Jul-20   something else

I want to display only unique values once along with the changing dates like this:

1, text, another value
01-Jan-20
07-Mar-20
20-Sep-20
30-Dec-20

2, text, something else
02-Feb-20
12-Mar-20
15-May-20
17-Jul-20

Should I modify the oracle query or utilize map/reduce on the resulting array in my programming language? Any suggestions or examples?

Answer №1

Here is a coding example

let dataObject = {};
`1   text 1  01-Jan-20   another value
1   text 1  07-Mar-20   another value
1   text 1  20-Sep-20   another value
1   text 1  30-Dec-20   another value
2   text 2  02-Feb-20   something else
2   text 2  12-Mar-20   something else
2   text 2  15-May-20   something else
2   text 2  17-Jul-20   something else`.split(/\n/)
.forEach(line => {
  let [_, num, title, date, val] = line.match(/(\d+)\s+(.*?)  (.*?)   (.*)/)
  // console.log("n",num,"t",title,"d", date, "v",val)
  if (!dataObject[title]) dataObject[title] = { num:num, val:val,dates:[] }
  dataObject[title].dates.push(date)
})

console.log(dataObject)

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

JavaScript and Responsive Design Techniques

I'm struggling to create a responsive page that starts with a mobile-first approach, but I keep running into the same issue. When I have my dropdown menu in the mobile version, it looks good. However, when I try to switch it to the non-mobile version ...

Guide to building an HTML table using an array of objects

Is there a way to dynamically create a table from an array of objects? Here's an example array: let data = [{name: 'Player1',score:10}, {name: 'Player2',score: 7}, {name: 'Player3',score:3}] The desired HTML output shou ...

The concept of setTimeout and how it affects binding in JavaScript

I have limited experience with jquery, mainly using it for toggling classes. However, I will do my best to explain my issue clearly. I have three div elements and when one is clicked, the other two should rotate 90 degrees and then collapse to a height of ...

Is it possible for the JTable constructor to accept data structures other than arrays?

public JTable(Object rowData[][], Object columnNames[]) Object rowData[][] = { { "Row1-Column1", "Row1-Column2", "Row1-Column3"}, { "Row2-Column1", "Row2-Column2", "Row2-Column3"} }; Object columnNames[] = { "Column One", "Column Two ...

Traverse the JSON array in a loop

I am currently facing an issue with looping through a JSON array that I am passing to PHP. At this point, I am only passing one array and receiving the same array back from the PHP file. While I can loop through the data in JavaScript, I am encountering er ...

What is the method to spin an item in three js while keeping its axis in focus?

Looking to rotate a globe object around its y-axis smoothly? I have come across a helpful function for achieving this: function rotateAroundObjectAxis(object, axis, radians) { var rotationMatrix = new THREE.Matrix4(); rotationMatrix.makeRotationAxis ...

Create a new object by mapping values from an array of two objects in Angular using TypeScript, based on the object

Here is a code snippet for a Question and Answer data structure: export class Question { id: string; title: string; description: string; answers: Answer[]; } export class Answer { id: string; text: string; questionId: string; } We have two ...

When using array_intersect, an error with Severity 4096 occurs stating that a stdClass object could not be converted to a string in the CodeIgniter

When trying to use 'array_intersect' on two arrays containing multiple values with stdClass objects, I encountered an error message stating "Severity: 4096 Message: Object of class stdClass could not be converted to string" Controller Code: ...

creating a picture within a frame

the code : function DrawFirstRow() { Position = 1; width = 84; height = 84; startX = 28; startY = 28; for (index = 0; index < canvasWidth; index += 28) { /// use += ctx.drawImage(tankImage, (Position ...

Using React js to transform objects into arrays for useState

Hey there! I'm currently working on a webshop demo project for my portfolio. I've encountered an issue while trying to fetch data from commerce.js. The data is in the form of objects, which are causing problems when I try to map them. I've a ...

Is it feasible to simultaneously load multiple directives in AngularJS?

I currently have a UI table with 5 columns, each containing different charts rendered using various directives such as custom progress bars and margin targets. The functionality is operating smoothly at the moment. Issue: When loading the page, it takes a ...

Navigating fluently in React Native applications

Struggling to grasp the proper implementation of navigation in RN? The provided code snippet should shed light on the current scenario. HeaderConnected is equipped with a menu button component that utilizes a custom navigate prop for opening the Drawer me ...

Angular JS effectively prevents redundant data from being displayed to users when scrolling infinitely while also efficiently removing DOM elements for previous data

I'm currently working on implementing AngularJS Infinite Scroll without using jQuery. My goal is to display the first 3 data items when the page loads and then load the next 3 data items from a JSON array object as the user scrolls. The issue I am fac ...

Transferring data between two TypeScript files of different Angular 2 components

I have two components, Component A and Component B, which are not parent-child components but I need to pass data from Component A to Component B. Example: Component A.ts has an array of data: myData: [ {'name':'some a','email& ...

The webpage does not dynamically resize based on screen height

Encountered an issue with the excess space below the footer. Resolved it by implementing a jQuery sticky footer as CSS techniques were unsuccessful. However, facing a problem with the main content of the webpage. Adjustment of .bg-photo's height impa ...

Utilizing D3 for embedding a background image in an SVG

After exploring different options, I have decided to switch from my previous Bootstrap framework to using a solid SVG strip with D3 for my project. The objective is to create 3 clickable triangles that will mask images and act as anchor links within the s ...

Display Buttons in a Horizontal Row and Highlight the Active Button

I am presenting four buttons that trigger POST requests, therefore they are enclosed in a form: <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784 ...

what is the significance of the number THREE in the context of Three.js?

Can you explain the significance of "THREE" in three.js? When we are creating a scene or any object, we typically use names like new THREE.Scene() or new THREE.WebGLRenderer(). What is the meaning behind the term "THREE" in this context? ...

Adding images dynamically into a Bootstrap modal when clicking using Angular's ng-repeat

I would like to create a page with photos where users can click on an image and have it enlarge in a bootstrap modal. The challenge is dynamically adding each specific image to the modal when clicked. Below is how my html currently looks: <div class="c ...

Troubleshooting API URL parameter problems

In my content management system (CMS), I am utilizing Laravel as a web API and AngularJS for making requests. An iframe is being used to call services with a direct link using the trusted src function. The issue I'm facing is that I cannot employ a s ...