Solved

Grouping the output of a SQL query and displaying it

Posted on 2004-10-12
1
157 Views
Last Modified: 2010-04-01
Hi all,

I have a query with a resultset similar to this:

type | amount
1 | a
1 | b
1 | c
2 | a
2 | b
3 | a

I want the display to look like this:

1 | a
   | b
   | c
2 | a
   | b
3 | a

This is similar to coldfusion and the cfoutput group attribute. Basically, I want anything with duplicates to be removed from the output (given that they are ordered correctly in the query). It is not only this query, it should apply to much larger queries with more columns.

Is there any type of tool to do this or do I have to write something that always checks the previous row's value and then displays whether or not it was the same as the current row?

thank you very much.

Jin
0
Comment
Question by:neojin80
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 19

Accepted Solution

by:
Kuldeepchaturvedi earned 125 total points
ID: 12296823
I think you can do this with a loop while creating the table.
Assuming that you have got them in ordered form.
<table>
<%
int myval=-1;
while(rs.next())
{%>
<tr>
<%
if(myval==-1 or myval=rs.getString(1))
{
myval=rs.getint(1)
%>
<td><%=myval%></td>
<%
}else
{%>
<td></td>
<%}
//rest of the processing.
}
%>

This should do the job
0

Featured Post

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you need to forecast numbers -- typically for finance -- the Windows and Mac versions of Excel 2016 have a basket of tools to get the job done.
First of all let me say that the only language that I speak is English, but in answering questions here I often come across people whose English skills are not the best and I’d like to be able to communicate better with them, and the following descr…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question