Archive for April, 2013

Picture Post: How we associate Value April 24th, 2013

Vinod Kumar

Price is what you pay, Value is what you get – Warren Buffet

The meaning for value is not understood by many of us. Value can be perceived as the worth we attach to something. This can be to almost everything in life – from materials, friendship, success, love etc. In this post, thought to share a visualization that I felt was very compelling and relevant.

Too many people overvalue what they are not and undervalue what they are – Malcolm S. Forbes

In this age of fast foods and buying power of parents have gone up. It is quite difficult to many to teach their kids the value for things they purchase. Keeping your kids happy is important, but making them earn it is even more critical in my opinion. Do we succumb to our weakness and want to give the best to our kids? Are we thinking in our decisions? Are we making them feel what it takes to own one? This generation kids are into tremendous peer pressure that they hardly know what it takes to fail, what it takes to earn your bread.

You don’t get paid for the hour. You get paid for the value you bring to the hour – Jim Rohn

How many of you agree to this concept? Do you think we don’t understand the value of something when we have it by our side – be it relationship, friendship, materials etc? Would love to hear your thoughts.

Continue reading...


Sliding Window based Aggregation–SQL Server 2012 April 19th, 2013

Vinod Kumar

As part of performance testing at MTC, I get a chance to meet a number of customers from the financial domain. A lot of code I see in applications is around creating custom functions for some simple requirements. One of the most sought after requirement is the need for sliding window operation. Did you know we have this function already with SQL Server 2012? When I talk with customers, a lot of them find it interesting and are mostly unaware of this enhancement made. In this blog post I will introduce this with pointers to more read. Having said that, you can also check some other functions which will mimic Access based functions introduced with SQL Server 2012.

Check the Sliding Window implemented using OVER Clause in MSDN.

Here is a typical example for sliding window implementation.

SELECT SalesDate, Sales,

AVG(Sales) OVER (

             ORDER BY SalesDate

             ROWS BETWEEN 10 PRECEDING AND 10 FOLLOWING) as [SlidingAverage]

FROM tbl_Aggregate


In this above example is a case of running average over a sliding window of rows of 10 previous (see PRECEDING keyword), current and 10 next rows (see FOLLOWING keyword).

We can also use the analytics functions introduced with SQL Server 2012 along with the above syntax.

To show how powerful queries can be made, below is a classic example. Let us create a simple budget table with values for allocation across the past 3 years.


(YearOfBudget INT, GroupName NVARCHAR(10), Budget DECIMAL)




      (2010, ‘Product’, 50000.00),

      (2010, ‘Support’, 30000.00),

      (2010, ‘Sales’, 40000.00),

      (2011, ‘Product’, 60000.00),

      (2011, ‘Support’, 40000.00),

      (2011, ‘Sales’, 50000.00),

      (2012, ‘Product’, 65000.00),

      (2012, ‘Support’, 45000.00),

      (2012, ‘Sales’, 55000.00)

Now that we have the data in place let us write a query which will show us side-by-side the current budget, previous budget and next years budget for a comparison perspective. This can be used for reporting type queries. We will be using two other analytic functions LAG and LEAD in addition to OVER clause.

SELECT YearOfBudget,




— Next Years’s budget

LEAD(Budget, 1, 0) OVER (PARTITION BY GroupName ORDER BY YearOfBudget ) as NextBudget,


–Previous Years’s budget

LAG(Budget, 1, 0) OVER (PARTITION BY GroupName ORDER BY YearOfBudget ) as PreviousBudget


FROM tbl_Budget

The output needs to be seen in 3 section (Product, Sales, Support) for our dataset. The below figure shows the same.


Hope you got an idea of such functions introduced with this version. So how have you used these functions in your environments? Would surely love to hear from you.

Interesting with the above query is, the Execution plan has a new operator added. It is called Window Spool. Window spool operator uses actual spool table to keep sliding window’s rows. It can use either in-memory optimized or tempdb based regular spool tables.


I remember writing about spills over Pinal’s Blog earlier and it is an important consideration. Always remember, optimizing TempDB is an important aspect and these analytic functions add-up to the overall experience. If spooling does occur to disk, you can view it via xEvent profiling too with SQL Server 2012. The event to add is: window_spool_ondisk_warning – Occurs when a Window Spool operator uses on-disk work table. I did write about using the new Extended Events UI in SQL 2012 for Monitoring high CPU over this blog.

Some fineprints as we sign off that you might find useful are:

  1. If PARTITION BY clause is not specified in OVER clause, entire source table is treated as single partition.
  2. If ORDER BY is not specified, ROWS/RANGE clause cannot be present and computation of each row will include entire partition.
  3. If ORDER BY clause is specified, but ROWS/RANGE clause is NOT specified, the default behavior is to have "RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW" to calculate current row aggregate value.
  4. For an index to be used by Window spool operator, all the columns in PARTITION BY and ORDER BY clause should be specified in composite index.
  5. If the query contains multiple different OVER clauses, only execution strategy in SQL Server 2012 is stacked operation. This means that we will sort for first OVER clause, execute aggregate, sort again for second OVER clause, and execute aggregate again. In the above example, you will see two Window Spool functions.
  6. ROWS clause is always faster than RANGE clause. If ORDER BY column is unique, then it is better to use ROWS over RANGE clause.

Thanks for reading this far. Keep exploring and making the best use of the power that TSQL functions introduce in every release.

Continue reading...


As a Leader, it is always your fault !!! April 16th, 2013

Vinod Kumar

I have written couple of posts on Leadership and management before over the blogs. In this blog post, let me take a different dimension to leadership and how I have seen people mistakes passing the buck when things go wrong. All I have to say to them is, STAND UP and OWN IT – aren’t you the much touted leader of your team?

As I said before, Leaders is someone who owns and *leads* the way for others to follow. Whenever you see someone taking a backseat and saying you did something wrong, well you surely have an attitude to deal with.

Never say, "oops."  Always say, "Ah, interesting."

IT is your fault – IF …

  1. … your team doesn’t get along with you.
  2. … your team misses the sales target.
  3. … people always take advantage of you.
  4. … you cannot control / moderate the conversations within the team.
  5. … your teams culture needs improvement or below par.
  6. … your team is not motivated enough to work harder.
  7. … employees do what they are directed and fail to execute out-of-box.
  8. … you are not respected. This needs to be earned.
  9. … your subordinates fail to understand you and don’t listen to you.
  10. … people need to know about you in the industry being a leader.
  11. … your self-confidence is low.
  12. … you don’t believe your team can succeed.
  13. … you cannot influence the leadership team to defend your team.
  14. … people give up even before giving their 100%.
  15. … you are not there when the team needs you.

The greatest mistake you can make in life is to be continually fearing you will make one – Elbert Hubbard

Parting words

It takes courage and confidence to stand up and accept failures. No one succeeded sitting on the sidelines. So as a leader, you need to show and guide your team in reaching the desired goal. Make new paths and don’t get stereotyped in your approach by what others have done.

Final words, look into what you could have done better rather than just finding faults with people around you. You are likely to have greater control to the situation which involves you. First, accept it was your fault in first place :). Be a leader, earn your respect.

Continue reading...


Saying Thank You – the forgotten art April 15th, 2013

Vinod Kumar

One can pay back the loan of gold, but one dies forever in debt to those who are kind.

Life these days are always a hurry and we tend to get into the situation that we forget some of the basics. It is said in management that on your way up make sure to keep people happy because when you come down they will be good to you. Though this concept is so true, life is demanding that we forget how others have helped us. I thought this will be a great way to bring the basic behavior into a blog post. When was the last time you said a thank you to your colleague or manager or subordinate or some random person at work? When was the last time you said a thank you to a friend?

Silent gratitude isn’t much use to anyone – G.B. Stern

Thank You while interviewing

This will be a special case scenario. How many of you have taken the time to send a thank you note to the HR / Manager who interviewed you? It is courtesy if you can do the same. A thank you note can always add a special consideration and be mild in your communication and avoid overdoing the same. What are your options for communication?

  1. Email
  2. Phone Call
  3. Handwritten note
  4. Text Messages
  5. Linked in communication

Though these are the most opted way of communication, I use the same order of preference too. Be professional in your communication especially via email and phone calls. It is just a small note to the person who took time in interviewing.

To say thank you, is in recognition of humanity – Toni Mont

Being Professional while thanking

There is no perfect way or a prescriptive mechanism to say thank you. Here are some tips I thought was worth sharing.

  1. While emailing or over phone call, be concise in your message and don’t try to ramble or write essays. No one has the time for these :).
  2. Don’t procrastinate and delay in your communication. Do it as soon as it is over.
  3. In an interview case, restate the qualities you bring to table as an reminder to interviewer. Also make sure to recollect a point or two from the interview itself to add as an reminder.
  4. A perfect thank you message brings a smile to readers or even better makes the reader feel special as they read.
  5. Don’t try to ramble or play with words. Get an second opinion with a friend to check if the words are out of place.
  6. Do a spell check, but also make sure spell checks don’t change the meaning of sentences.
  7. Be polite in your communication. Don’t forget to have a proper subject in your email.

Feeling gratitude and not expressing it is like wrapping a present and not giving it – William Arthur Ward

Final words

I am a big fan of hand written letters. Trust me, when was the last time you did write one? In my opinion hand written messages are more personal and has bigger impact when delivered correctly. What are your thoughts? What are you comfortable doing?

Continue reading...


Writing–what goes behind my mind? April 8th, 2013

Vinod Kumar

Recently I was questioned by someone asking – what literally goes behind my mind when I start writing for blog and more so for books. The question was simple but yet got me thinking hard. I thought to pen them down and give some simple tips that I would suggest people while writing. Writing is different from presentation skills and that is different from being able to articulate on a given subject. Though these tips are a great start, there is no substitute to being consistent. Only practice will get you seasoned and that is your best way to learn things.

Writing in general requires a mindset that we need to be prepared for, you need to have it as an habit. What you write is something for a later discussion. I do recollect writing a Blog post around “Why do we blog?”. Even though I have managed to publish a book, I don’t quite yet consider myself as a real writer. There is tons to learn and many a miles to go for me individually too.

There are no set rules or guiderails to become seasoned writer. So here are some tips that come to my mind as you embark your journey to becoming a writer.

  1. Have an open attitude and be curious in exploring your subject.
  2. Hear the feedbacks and make sure to take the learnings back.
  3. Don’t turn away any form of criticism.
  4. Keep validating your assumptions.
  5. Write to stimulate the mind.
  6. Don’t shy away from getting out of your comfort zone.
  7. Think like a reader when you start writing.
  8. Share your experience in short para’s.
  9. If you are not sure about something, accept you don’t know and refrain from being an expert in it.
  10. Every experience can teach a lesson, so don’t dismiss them.
  11. Being yourself is important. Don’t try to be someone else.
  12. Don’t do a B grade job, if you are not happy – Don’t publish.
  13. Who said writing is an art. Once you get used to it, it is like talking with a friend on the online world :).
  14. Try to keep it simple. Keep sentences it short.
  15. Limit on the adjectives – express the concepts clearly. Let the readers put a suitable adjective.
  16. Don’t overwrite, make it a comfortable read.
  17. Set some uninterrupted time aside for writing.
  18. You need to get the flow in your head right before starting / writing a single word.
  19. Start with stories or nice metaphors to get your readers attention.
  20. Have a nice caption. It has taken me years and I am still learning this.
  21. Put your heart into your content, let it speak and beat than mimicking someone else.
  22. Try to make lists, bullets and headings to make an easy read.
  23. Make it long enough to cover the concept but short enough to make it interesting.
  24. Write what works for you and your readers.
  25. Write with the flow first and then look for inaccuracies.
  26. Keep a schedule for what you write, this creates consistency.
  27. Make a note of ideas that come your way. Chip them one after another.
  28. Force yourself into a habit. I do it 30-60 mins once in 3 days. You can have a different schedule.
  29. Start writing ahead of time and don’t force something to be published. You don’t need to be perfect, but you don’t need to rush it out either.
  30. Have basic word limits. I know a friend who always write minimum of 500 words in every blog. That is so tough.
  31. Add emotions and life into your stories.
  32. Write without distractions around you.
  33. Read as much as you can. This gives you an idea how others write and think.
  34. Make your own unique style. You don’t need to be like others.
  35. Never trust what a spell checker does. It can be crazy sometimes :).
  36. When in doubt, omit the sentence.
  37. Try to read out what you wrote and you will find the mistakes.
  38. Allow your mind to go all over the place as you write. You will become creative for sure.
  39. Don’t wait for ideas to come your way. Write them as it comes.
  40. Don’t miss the opportunity to read your comments, there is a treasure of wealth that can inspire you with some great ideas.

So here are my Top 40 tips to writing. I am sure this is not complete or comprehensive to what you have in mind. But this can surely be a great start if you are into writing. Thanks again for reading this far and I hope you will get inspired in writing more and more. Feel free to drop a line if you have learnt something.

Continue reading...