Monthly Archives: March 2009

2 down 3 more to go

Yes people it doesn’t happen all time to me but this year 2009 I’m walking the road that I decided to go through 4 months ago.

Now I will be happy to strike off 2 items from the list.

  1. Lose that 10 pounds that I gained last year. I have already started working on it and lost 3 7 pounds in a month so I expect to lose that 10 by end of April 2009. Its slow but works for me.
  2. Get my parents to USA one that has been failing for the last 2 years.
  3. Jump into Adobe Flex.
  4. Talk/read less about the srilankan ethnic issue which I was doing a lot during 2008. Its just too dragging and I have strong appetite to read about it so I’m planning to reduce that appetite.
  5. Increase my blogs viewers base and posts more on tech rather than on politics. It would be hard since 2009 is a election year in India.

I thought loosing the weight would be the hardest but eventually that was not hard but to control  my appetite to read the Srilanka issue was the hardest. Still I read about it here and then but I have completely stopped my urge to blog about it.

With elections coming up in India Google sends in more traffic for the electoral list search post.

Getting my parents here is still a mystery :)

Still 8 more months to go and I hope I will be done with the other 2 as well.

“Start from where u r then where u want to be”..

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.

Never ending Surangani..

Some songs just don’t die just like the Batman,spider man or the Friday the 13th movies.

Same like that the Surangani baila song from Srilanka was remixed in tamil in the past and now the Surangani remix by Dinesh Kanagaratnam yet again adapted in tamil movie called ‘taxi TN O7 AL 4777‘ and its one of the best remixes I have listened in recent times.

Surangani tamil remix called Aathichudi  from taxi TN O7 AL 4777.

The original video track was removed from Youtube hence i’m including just the audio track from youtube.

Surangani Remix  by Dinesh. I personally like this one..

Original Surangani sinhala track probably who ever listened to Ceylon radio would know this song.

Original Surangani track adpated by an old tamil movie. Not so great though..

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

Switch to our mobile site