October 1, 2008 at 4:25 am
All,
I hope all of you know about Mr Jeff's Tally table. I also believe your people knows the usage of Tally table. Here i have listed out the usage of Tally table(so far i implemented that table in my work)
1) Splitting delimited values
2) Finding Palindrome
3) Date/Months generation
4) Displaying pyramid format output
5) Identifying the duplicate letters from a string
is there any other points that i missed out ? I hope the list should grow further. Also is there any other important usage that i missed out ?
karthik
October 1, 2008 at 5:56 am
Fuzzy dedupe:
[font="Courier New"]-- Self fuzzy match
SELECT t.VendorID, r.VendorID AS Dupe, COUNT(*) AS TokenCount
FROM FuzzyInputFile r
INNER JOIN [Numbers] n ON n.number < LEN(r.VendorName)
INNER JOIN FuzzyInputFile t ON t.VendorID <> r.VendorID
AND CHARINDEX(SUBSTRING(r.VendorName, n.number, 3), t.VendorName) > 0 -- 3 is token size, tune to data
WHERE n.number < 30 -- VendorName column length
GROUP BY t.VendorID, r.VendorID, t.VendorName
HAVING COUNT(*) / CAST(LEN(t.VendorName) AS NUMERIC (5,2)) > 0.4 -- Cutoff: tune to data
[/font]
Cheers
ChrisM
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
October 3, 2008 at 2:12 am
Any more usages apart from that chris & mine mentioned?
karthik
October 3, 2008 at 4:33 am
As I understand you are listing the things what can you do with Tally Table!?
In my experience I used Tally table to find out the missing numbers in my Identity column!
so from me is another one:
6) Finding missing numbers in Identity Column
Another thing here it would be better if this topic goes as Article with Title "All what can you do with Tally Table ( Jeff's Table)" and I'm sure that Steve can do it but first of all we must put the things what we have done with tally table!
Dugi
October 5, 2008 at 11:50 pm
Concur...
If it comes as an article it would be useful for lot of folks.
karthik
October 6, 2008 at 5:51 pm
In addition to dates, it's useful for generating any range of numbers, such as invoice numbers, where you might be looking for gaps. If I wanted to test the range A10000-A19999 in the invoice table for gaps, I could use the following:
Select 'A'+cast(10000+N-1 as varchar(10)) as InvNo
from tally t
left join invoice i on i.invno = 'A'+cast(10000+N-1 as varchar(10))
where N <= 10000
and i.invno is null
October 7, 2008 at 1:14 am
Anybody want to add some more points ?
karthik
October 7, 2008 at 3:08 am
Till now we have 7 + fuzzy dedupe from Chris Morris ...ooops it seems 8!
1) Splitting delimited values
2) Finding Palindrome
3) Date/Months generation
4) Displaying pyramid format output
5) Identifying the duplicate letters from a string
6) Finding missing numbers in Identity Column
7) Generating any range of numbers
:w00t:
October 7, 2008 at 6:56 am
I've used it for "cleaning" data... you know... remove all numbers, remove everything but the numbers, remove special characters, remove adjacent multiple spaces (although there are better ways to do that).
The "Tally" table is just my name for a "Numbers" or "Auxilary Numbers" or "Helper" table. Do an internet search for those other terms and I'm sure you'll come up with more uses. I've used it for some of the darnest things, but I can't remember what those oddities were...
--Jeff Moden
Change is inevitable... Change for the better is not.
October 7, 2008 at 7:23 am
Jeff Moden (10/7/2008)
I've used it for "cleaning" data... you know... remove all numbers, remove everything but the numbers, remove special characters, remove adjacent multiple spaces (although there are better ways to do that)....
Jeff you are not allowed to post here, you can just check the possibilities what can do others with your Tally Table and then collect them and writing another Article with all things that we can do with that table!
:hehe::hehe::hehe:
Little joke here ...plz make an Article collecting every sample with tally table! We are here to post the scripts what we have done so you just generalize them if it possible!
October 7, 2008 at 7:32 am
Dugi (10/7/2008)
Jeff Moden (10/7/2008)
I've used it for "cleaning" data... you know... remove all numbers, remove everything but the numbers, remove special characters, remove adjacent multiple spaces (although there are better ways to do that)....Jeff you are not allowed to post here, you can just check the possibilities what can do others with your Tally Table and then collect them and writing another Article with all things that we can do with that table!
:hehe::hehe::hehe:
Little joke here ...plz make an Article collecting every sample with tally table! We are here to post the scripts what we have done so you just generalize them if it possible!
Heh... now that's funny... me not posting on a thread with "Tally Table" in the title. Ok... I get it, Dugi. π
--Jeff Moden
Change is inevitable... Change for the better is not.
October 7, 2008 at 7:50 am
An article would be fun, I've already seen several uses I haven't tried yet.
Karthik, you were first to suggest it (within this thread anyway). You going to write us an article detailing the many uses of Tally tables?
Or are we waiting for Porkslinger π to give us another followup article?
Perhaps we should have a race and see whose article gets published first!
---------------------------------------------------------
How best to post your question[/url]
How to post performance problems[/url]
Tally Table:What it is and how it replaces a loop[/url]
"stewsterl 80804 (10/16/2009)I guess when you stop and try to understand the solution provided you not only learn, but save yourself some headaches when you need to make any slight changes."
October 7, 2008 at 7:55 am
jcrawf02 (10/7/2008)
An article would be fun, I've already seen several uses I haven't tried yet.Karthik, you were first to suggest it (within this thread anyway). You going to write us an article detailing the many uses of Tally tables?
Or are we waiting for Porkslinger π to give us another followup article?
Perhaps we should have a race and see whose article gets published first!
heyyy heyy I suggest for Article not Karthik ok! - :w00t:
October 7, 2008 at 8:22 am
jcrawf02 (10/7/2008)
Or are we waiting for Porkslinger π to give us another followup article?
Heh... what an idea... maybe I'll title it "Porkslinger: Have Chops, Will Travel." π
--Jeff Moden
Change is inevitable... Change for the better is not.
October 7, 2008 at 8:51 am
Another use.
Generating Universal Product Code numbers.
UPC-12 is PPPPPP-NNNNN-C (hyphens added for clarity)
P: 6 digit company prefix assigned by EAN Council
N: 5 digit sequential number
C: check digit, based on modulo-10 calculation.
The tally table allows inserting 100,000 - 1 numbers (00000 to 99999) in the UPC_Numbers table in a single INSERT statement, rather than the RBAR way of looping one insert at a time and incrementing aocunter each time.
Performance gain is HUGE. Generating two UPC sets using RBAR took 38 minutes. This went down to 45 seconds using Tally table.
Or any other numbering sequence based on consecutive numbers.
RBAR inserts are poison in large quantities.
Viewing 15 posts - 1 through 15 (of 66 total)
You must be logged in to reply to this topic. Login to reply