Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Standard view
Full view
of .
Look up keyword
Like this
0 of .
Results for:
No results containing your search query
P. 1
Eliminate Duplicates frm sql2005 tables

Eliminate Duplicates frm sql2005 tables

Ratings: (0)|Views: 52|Likes:
Published by sony
this query does to remove the duplications for table its a hify 1 try this
this query does to remove the duplications for table its a hify 1 try this

More info:

Published by: sony on Dec 31, 2009
Copyright:Attribution Non-commercial


Read on Scribd mobile: iPhone, iPad and Android.
download as DOC, PDF, TXT or read online from Scribd
See more
See less





Eliminate duplicates
--**************************************---- Name: Eliminate duplicates-- Description:To elminate duplicates fr-- om results from table in which version h-- istory exists so you have the most curre-- nt data only output to screen.-- By: James Travis---- Assumes:In SQL you can use subqueries-- to build a result of data which you can-- join back to the table. The subquery ac-- ts as a base line of key values to make-- duplicates disappear while still allowin-- g verions of preiovus data to exist in t-- he same table.---- Assume you have a situation like this-- .-- Your company has a list of products t-- hat occasionally changes but you want to-- keep the previous price. They want to c-- harge the current rate while still havin-- g the previous rate in the same table. T-- hey also want to be able to print a repo-- rt which list all products current price-- .---- Our table looks like this:---- Name: ProdPrice---- Col1: ProdID-- Col2: EffDate-- Col3: Price---- Col1 and 2 are the Clustered Primary-- key so we can keep products together in-- order of their effdate when price change-- d. This is ideal in a product environmen-- t as you want to access the products mos-- t current price as fast as possible.------SELECTProdPrice.*FROMProdPriceINNER JOIN(SELECTProdID, Max(EffDate)ASEffDateFROMProdPriceGROUP BYProdID )ASCurrDataONProdPrice.ProdID = CurrData.ProdIDAND 

You're Reading a Free Preview

/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->