all groups > sql server programming > december 2005 >
You're in the

sql server programming

group:

Sort to display without duplicates


Sort to display without duplicates den 2005
12/18/2005 11:54:02 PM
sql server programming:
Hi everybody,
I like to asked anyone who is very good at sql to help me display this
data in a table format that duplicate headings, subheadings or other columns
won't appear twice or more. Can anyone help me? I need to sort them and load
them in a Datatable. Loop thorugh all records and display them in a label
control created at run time. Thanks in advance.

Sample Data:

Topics Table
TopicId TopicLevel Topic ParentId
1 1 First 0
2 1 AnotherFirst 0
3 2 Second 1
4 2 AnotherSecond 2
5 3 Third 3

Contents Table
ContentID Heading SubHeading SubSubHeading1 NumberText Names Content1
ParentId
1 How are you? Hello Someone 1 Ben some
text 5
2 How are you? Hello Someone 1 John other text 5
3 How are you? Hello Anybody 2 Ben some
text 5
4 How are you? Hello Anybody 2 Mike other
text 5
5 How are you? Greet Anywhere 1 Ben some
text 5
6 How are you? Greet Anywhere 1 Luke some
text 5
7 I miss you. Really When null null some
text 5
8 I miss you. Really When null null some
text 5

Display Format:
How are you?
----------------------------------------------
Hello
-----------------------------------------------
1 Someone
----------------------------------------------
Ben some text
---------------------------------------------
John other text
---------------------------------------------
2 Anybody
---------------------------------------------
Ben some text
---------------------------------------------
Mike other text
--------------------------------------------
Greet
-------------------------------------------------
1 Anywhere
-----------------------------------
Ben some text
-------------------------------------
Luke some text
================================================
I miss you
--------------------------------------------------
Really
------------------------------------------------
When
-----------------------------------------------
some text
----------------------------------------
some text
------------------------------------------


den2005
--
Re: Sort to display without duplicates John Bell
12/19/2005 10:00:33 AM
Hi

Check out http://www.aspfaq.com/etiquette.asp?id=5006 on how to post usable
DDL and example data also posting the expected results from the example data
would be useful. How your content relates to the topic is not clear, if
there is a relationship then you will (probably) need to join the two tables
on the related columns see the topic "Using Joins" in Books online.

Assigning your data values to a label would require client code.

John


[quoted text, click to view]

Re: Sort to display without duplicates Uri Dimant
12/19/2005 11:08:55 AM
Den
Why not doing such thing on the client side?



[quoted text, click to view]

Re: Sort to display without duplicates den 2005
12/19/2005 3:56:02 PM
Thanks for replies, Uri and John

Simply I like to find out if there is a sql statement to be able to do this
in sql and not in application, but basically I like to sort the data and
isplay them ass hown without duplicates and joins simply not quite
applicable, it would be complicated and might not return what I like, Is join
applicable on same table, the data I like to sort comes from same table.

den2005
--
MCP Year 2005, Philippines


[quoted text, click to view]
Re: Sort to display without duplicates John Bell
12/20/2005 1:30:03 AM
Hi

Yes you can have self joins, you may want to look at using DISTINCT or
possibly using GROUP BY. As always Books Online would be the first place to
look these up!

John

[quoted text, click to view]
AddThis Social Bookmark Button