User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the MS SQL section within the Web Development category of DaniWeb, a massive community of 392,022 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,268 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our MS SQL advertiser:
Views: 2464 | Replies: 2
Reply
Join Date: May 2005
Posts: 1
Reputation: chai is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
chai chai is offline Offline
Newbie Poster

grouping unique name in table

  #1  
May 24th, 2005
Hi!

i have a table with 3 fields: ParentFolder,DocumentNo and VersionNo
the DocumentNo give each document a unique number. ParentFolder is a number specifying which folder a document is in. and each document(with same name) can have many VersionNo(1,2,3 etc).

i am creating a house keeping function for user. this function accepts a number from user specifying how many version he would like to keep.

i have created a page that list out all folder in the db with a checkbox. user is able to checked the folder they want to housekeep.

the problem is how do i write a sql that will 'group' documents with same name, delete the document base on the input.

since the system only get the folder id and not each document id individually the system won't be able to pinpoint each document.

in dire need of help
Thanks in advance
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jun 2005
Location: Texas
Posts: 120
Reputation: jwshepherd is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 5
jwshepherd's Avatar
jwshepherd jwshepherd is offline Offline
Junior Poster

Re: grouping unique name in table

  #2  
Jun 16th, 2005
you will either need to add a second table to keep track of document names and Document numbers relations or add a DocumentName Column to your table.
Reply With Quote  
Join Date: Jun 2005
Location: Nothamptonshire
Posts: 27
Reputation: pclfw is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 1
pclfw pclfw is offline Offline
Light Poster

Re: grouping unique name in table

  #3  
Jun 25th, 2005
Sounds like work for a stored procedure.
The problem being that the easiest way to do this is to have a sub-query select the documents grouped on the parentfolder and documentnumber, and use a 'TOP X' qualifier. Then have the main select query use the output of the subquery with the NOT IN comparison.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb MS SQL Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the MS SQL Forum

All times are GMT -4. The time now is 10:47 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC