ALA-(GU)-KA-(NNA)-N

Past dies as we speak Future comes as we speak present is what we speak

How to identify and delete duplicate records from sql table

Well I’m sure any SQL developer out there would have encountered a problem where the duplicate records in a table have to eliminated for some reasons.

I recently encountered a similar situation where I had to remove the duplicate user name from a table with just one simple query . Here is how I did it:

Here is my tbl_username table having the following columns UID( auto increment primary key), uname (varchar(100)), fname (varchar(100)):

UID Uname fname
1 xyz xyz
2 xyz xyz
3 abc abc
4 qwerty qwerty
5 qwerty qwerty

We would have to remove the duplicate user names in order to do that we first build a sub query that picks up the uname and max id of the duplicate records.

Select uname, max(UID) as latestUID from tbl_username group by uname having count(uname) > 1

Result:

Uname latestUID
xyz 2
qwerty 5

By using the max function we can pick the latest entry to be deleted if you like to pick the lowest use the min() function.

Well if you have got this then its pretty much simple to get the build another sub query on top of this to get the unique IDs and then delete it as usual.

delete from tbl_username
where UID in
(
select latestUID from (
Select uname, max(UID) as latestUID from tbl_username group by uname having count(uname) > 1
)
)

Now the table has the following data in it

UID Uname fname
1 xyz xyz
3 abc abc
4 qwerty qwerty

Well this way of deleting would only work if the table uses an integer as a primary key.

This is the cure but prevention of this kind of situation can be resolved by just using unique keys on the Uname field.

Prevention is always better than cure so grab a SQL book if you have done this mistake.

1 Comment »

Square root day – 03/03/2009

Well I was reading this CNET news which was about square root day falling tomorrow i.e. 03/03/09 which occurs only 9 times in a century.

Tuesday is Square Root Day, a rare holiday that occurs when the day and the month are both the square root of the last two digits of the current year. Numerically, March 3, 2009, can be expressed as 3/3/09, or mathematically as √9 = 3, or 3² = 3 × 3 = 9.

I know its absurd but I have my own reasons to post about it.

The following are the square root days if you have failed in second grade

  1. 01/01/2001
  2. 02/02/2004
  3. 03/03/2009
  4. 04/04/2016
  5. 05/05/2025
  6. 06/06/2036
  7. 07/07/2049
  8. 08/08/2064
  9. 09/09/2081
No Comments »

India Electoral Roll List search

Yet again I was immersed  reading Wikipedia articles and I found a site that basically provides search interface to search the electoral roll list of India.

With elections on the way  this tool would avoid people from visiting the poll booth and return back with out voting since they aren’t in the list. It can be accessed from the below link.

http://search.eci.gov.in/

BTW I’m not sure if it really works because I kept encountering this login pop up which was annoying so I found the site for Tamil Nadu Election commison to check if I was there in the list.

One more you need to download their own tamil fonts and install. I know..

Bummer TN election has a search interface with Under construction message.  They do have another form which gives out tamil pdf for district – Constituency ward list for each of them.

Again bummer its in tamil so I can’t search in firefox or inside pdf which is a pain. So I had to literally read through all names in my ward and to every ones surprise I’m not listed :cry:

Waste of time. One good thing now I know my neighbours name and avoided a trip for my dad to check out the list.

Yamm Petra Inbam intha Vaiyakamum peratum..

No Comments »

Palm Springs 2009 trip

I just visited palm springs today and the weather was good.  As per the tram that’s marvel of engineering going from 2500 ft to 8500ft in 10 minutes you can’t beat that.

Well if you are near by its good to visit now since there is lot of snow out there and probably melt away in a a fortnight. So get moving..

No Comments »

End of Tax Season 2008…

Generally I procrastinate filing the tax every year but this year I filed it too early considering my standard.

Although I’m not getting much in federal and paying some to CA :( tax its the free e-file feature, sudden interest to file my tax and get the return before federal govt goes bankrupt  ;)   that motivated me to file early.

Thanks to FreeTaxUSA.Com for providing free federal tax return using the coupon code ‘FEDFREE‘.

People say California is on the verge of going bankrupt but still they made to provide this free e-file tool called CalFile which is pretty good. Instead of free e-file California can just remove the state tax itself :twisted: , I wish……..

Both the free e-file option are basic  and it should be good for most of my single friends in H1b or in F1 OPT.

Free aaah Kudutha ……. :lol:

No Comments »

Slumdog Millionaire is Slum

Yes the title says it. Its a really good desi masala movie packed in a nice little tamper proof plastic cup so that it can be cooked instantly in your DVD player.

As I was watching it I was wondering why it got nominated for Grammy and Oscars come on people haven’t you watched a better movie in your language.

I’m still wondering when was the last time Indians talked in Millions we follow the Indian Number system which is lakhs and crores.  The kids playing cricket reminds of  Chennai 28 which was a good movie.

Hell yeah this movie wasn’t  made for Indians it was made for the International community who are curious to know/learn about Mumbai after the November 26,2008 Mumbai attack.

Well there is one thing this movie has is A.R. Rahman but the Jai ho sounds similar to a track from Om Shanti Om and I’m not sure which song it is.

Its good marketing guys but don’t expect this to run this movie in India you know the result.

If only Kamal Hasan learns to market like these guys his Virumandi one of the best movies I have ever seen would have won a national award at least.

If you liked this movie then try watching yet another master piece called Pesum Padam/Pushpak from Kamal.

2 Comments »

தை பொறந்தா வழி பொறக்கும் தங்கமே தங்கம்

Thai Piranthal Vazhi Pirakum is an old tamil saying which means as the tamil calendar month of Thai is born you will find solutions to all your problems.

This year its true in my case since I finally got out of my cycle of cold -flu – bronchitis with this new month. Although doctor prescribed the medicine and I took it but still it counts as an solution right ain’t it.

Happy Pongal..

Here is the original lyrics from the song. Video Link for the song.

தை பொறந்தா வழி பொறக்கும் தங்கமே தங்கம் தங்க‌ ச‌ம்பா நெல் விளையும் தங்கமே தங்கம்

ஆடியிலே வெதை வெதைசோம் தங்கமே தங்கம்
ஐப்ப‌சியில் க‌ளை எடுத்தோம் தங்கமே தங்கம்
கார்த்திகையில் க‌திராச்சி தங்கமே தங்கம்
கார்த்திகையில் க‌திராச்சி தங்கமே தங்கம்
க‌ழ‌னியெல்லாம் பொன்னாச்சி தங்கமே தங்கம்
தை பொறந்தா வழி பொறக்கும் தங்கமே தங்கம்
தங்க‌ ச‌ம்பா நெல் விளையும் தங்கமே தங்கம்

க‌ன்னிய‌ரின் ம‌ன‌சு போலே தங்கமே தங்கம்
க‌ல்யாண‌ம் ஆகும‌டி தங்கமே தங்கம் ஆமா !
க‌ன்னிய‌ரின் ம‌ன‌சு போலே தங்கமே தங்கம்
க‌ல்யாண‌ம் ஆகும‌டி தங்கமே தங்கம்
வ‌ண்ண‌ம‌ணி கைக‌ளிலே தங்கமே தங்கம் ஆகா !
வ‌ளையல்களும் குலுங்கும‌டி தங்கமே தங்கம்
தை பொறந்தா வழி பொறக்கும் தங்கமே தங்கம்
தங்க‌ ச‌ம்பா நெல் விளையும் தங்கமே தங்கம்

முத்துச‌ம்பா நெல்லு குத்தி தங்கமே தங்கம்
முற்ற‌த்திலே சோறு பொங்கி தங்கமே தங்கம்
குத்து விள‌க்கேற்றி வ‌ச்சி தங்கமே தங்கம் ஆமா
குத்து விள‌க்கேற்றி வ‌ச்சி தங்கமே தங்கம்
கொண்டாடி ம‌கிழ்ந்திடுவோம் தங்கமே தங்கம்
தை பொறந்தா வழி பொறக்கும் ….


3 Comments »

Nathigar Vizha 2006

I have always wanted to do an podcast about superstitious beliefs that we have in our society and existence of god himself but Director Seeman has given a better speech with more facts.

If you know tamil and are atheists or a person looking out for an answer then you might like it for others its abusive so please stay away. You should have patience as well bcz seeman brags abt himself a lot in his speeches.

I wonder why the so called pro-ltte sites which carry all speeches of Seeman didn’t carry this one. May be they aren’t atheist who just need the support of Seeman’s speech alone.


NATHIGAR VIZHA 2006 SEEMAN 1
Uploaded by PERIYAR

NATHIGAR VIZHA 2006 SEEMAN 2
Uploaded by PERIYAR

NATHIGAR VIZHA 2006 SEEMAN 3
Uploaded by PERIYAR
No Comments »

I’m not Sita – ur not Rama either

I have faced this situation n number of times every where I lived in United states of America whenever there is a talk about India or going to Hindi movies.

I’m going to redirect them to this post to find my answer because I’m tired of telling each of them individually.

There is a wide spread accusation that people from Tamil Nadu (India) don’t speak or hesitate to learn Hindi and they should speak it since its a national language. I can’t talk for the whole tamil speaking people but here is my answer to it

  1. If the need araises then I will learn hindi which I don’t see happening in near future.
  2. I’m too lazy to learn and Hindi would be the last thing I would even consider learning.
  3. I tried learning once hindi as a kid and failed miserably hence I’m staying away from it.
  4. I don’t have to prove my nationality by learning Hindi.
  5. I’m happy watching Hindi movies using sub titles.

No offense guys we can always communicate in english which I beleive every one of my friend knows.

4 Comments »

How did my blog perform in 2008?

Well here are the statistics that I got from Google Analytics for my blogs during the period July 9 2008 to December 31 2008.

I’m actually surprised and happy after going through the statistics and thank you for taking 2 minutes off your precious time to read my blog and listen to my podcast.

This year I would like to extend my visitor base from my family/friends to common users which would be a tough task to do but will it give it a shot.

Well the next goal would be to get my name added to Google Suggest.

Please do leave your comments especially when my posts are bad.

Visitor Statistics

  • Total no of visits – 1232
  • Total page views – 2743
  • Pages/Visit - 2.23
  • Avg. Time spent on site – 2 minutes 5 seconds
  • Total no of Unique visitors – 856
  • Blogs visited from 45 different countries (PDF Report). The top 5 countries  and the no of visits associated with them.
    1. USA – 651
    2. India – 295
    3. Germany – 51
    4. Austria – 35
    5. Canada – 33
  • Highest no of Unique visitors : 23 on Dec 18 2008. Not a day with out a unique visitor.
  • Browser Statistics:The Top 3 browsers with their visits
    1. Internet Explorer-577 (46.83%). People please use anything other than IE :) .
    2. Firefox-529(42.94%)
    3. Chrome- 52 (4.22%)

Top 5 Content and their no of pageviews:

  1. Root – 487
  2. Yahoo Power user – 131
  3. Thanksgiving trip 2008 – 83
  4. Kathal mannan – 76
  5. Raman Andalum Ravanan Andalum Ennaku oru Kavalai Illai – 65

My Podcast Statistics:My Podcast Statistics

1 Comment »

Switch to our mobile site