# Tuesday, December 7, 2004

SQL Server 2005 adds the functionality of a Ranking expression that can be added to your resultset that is based on a ranking algorithm being applied to a column that you specify. This will come in handy in .NET applications for paging and sorting in a grid as well as many other scenarios.

 The most basic new ranking function is ROW_NUMBER(). ROW_NUMBER() returns a column as an expression that contains the row’s number in the result set. This is only a number used in the context of the resultset, if the result changes, the ROW_NUMBER() will change. The ROW_NUMBER() expression takes an ORDER BY statement with the column you want to use for the row count with an OVER operator as shown here:

Select SalesOrderID, CustomerID,

            Row_Number() Over (Order By SalesOrderID) as RunningCount

From Sales.SalesOrderHeader

Where SalesOrderID>10000

Order By SalesOrderID

 

Results are shown here:

 

SalesOrderID CustomerID  RunningCount

------------ ----------- --------------------

43659        676         1

43660        117         2

43661        442         3

43662        227         4

43663        510         5

43664        397         6

43665        146         7

43666        511         8

43667        646         9

...More

Alternatively if you have an ORDER BY clause in your result set different than your ORDER BY in your ROW_NUMBER() expression

--Row_Number using a unique value, different order by

Select SalesOrderID, CustomerID,

            Row_Number() Over (Order By SalesOrderID) as RunningCount

From Sales.SalesOrderHeader

Where SalesOrderID>10000

Order By CustomerID --Different ORDER BY than in Row_NUMBER

 

The result is shown here:

 

SalesOrderID CustomerID  RunningCount

------------ ----------- --------------------

43860        1           202

44501        1           843

45283        1           1625

46042        1           2384

46976        2           3318

47997        2           4339

49054        2           5396

...More

If you choose the ROW_NUMBER() function to run against a non-unique column, it will break the tie and still produce a running count so no rows will have the same number. For example, CUSTOMERID can repeat in this example and there will be several ties, SQL Server will just produce a monotonically increasing number, which means nothing other than the number in the result set as shown here:

Select SalesOrderID, CustomerID,

            Row_Number() Over (Order By CustomerID) as RunningCount

From Sales.SalesOrderHeader

Where SalesOrderID>10000

Order By CustomerID

The result are shown here:

SalesOrderID CustomerID  RunningCount

------------ ----------- --------------------

43860        1           1

44501        1           2

45283        1           3

46042        1           4

46976        2           5

47997        2           6

49054        2           7

50216        2           8

51728        2           9

57044        2           10

63198        2           11

69488        2           12

44124        3           13

. . . More

Tomorrow RANK()...

posted on Tuesday, December 7, 2004 4:19:45 PM (Eastern Standard Time, UTC-05:00)  #    Comments [10] Trackback
# Monday, December 6, 2004

Anyone who ever used illegal steroids should be banned from the game, or Pete Rose should be allowed in. Lacking any integrity at this point Bud Selig (and Kofi Annan) must resign. He presided over this sham and lets the players union walk all over him. We don’t have this problem in the NFL because we have a strong commissioner. In Baseball if you fail a drug test you have too many chances to hide it or try again. Baseball needs to get tough.

posted on Monday, December 6, 2004 4:15:16 PM (Eastern Standard Time, UTC-05:00)  #    Comments [16] Trackback
# Sunday, December 5, 2004

We did a New York Road Runners Race in Central Park on Saturday-15k (9.3 miles). The pace we did in this race would put Linda and I on a 4+ hour marathon. Antarctica here we come...


 
Last Name


 

First Name


Sex/
Age


 
Bib


 
City


 
State


Finish
Time


Pace/
Mile

GURBISZ

KATHLEEN

F27

4288

NEW YORK

NY

1:23:52

9:01

VAROLI

LINDA

F33

5528

NEW YORK

NY

1:25:30

9:11

FORTE

STEPHEN

M32

4142

NEW YORK

NY

1:25:34

9:12

posted on Sunday, December 5, 2004 9:11:55 PM (Eastern Standard Time, UTC-05:00)  #    Comments [2] Trackback
# Wednesday, December 1, 2004

When you think of the Microsoft Regional Directors what usually comes to mind are really amazing speakers at conferences like DevDays, Tech*ED (last year we had two RDs place #1 at two Tech*Eds) and the North Africa Developers Conference. You think of great authors and things like .NET Rocks.

 

RDs are truly great. But even if you collect together 150 amazing colleagues from around the world and put them all in a room together, there would be nothing without the proper organization. Leadership is key. General George Washington was less of a man (and General) without Martha (just ask the solders who she brought socks to).

 

For the past three years I have had the pleasure or working with the best PM at Microsoft, Eileen Crain. As of today Eileen is no longer the PM of the Regional Director Program or as I like to refer to it, the “RD Mom”. She has went on to bigger and better things at Microsoft.

 

Eileen has worked behind the scenes to make sure that the RDs got speaking engagements, in front of large customers, or any other kind of exposure. She also would always offer to take us out to dinner when we were in town! (Or drive me home when I drank too much. ). Whether it was planning a new marketing initiative or RD party at Tech*ED, she did it very thoroughly.

 

The RD program has been around for over 10 years and in years past you only heard of RDs at DevDays. Eileen has worked real hard to make us knows-and it worked. In the last few years the visibility of the RDs has grown and it is all due to Eileen.

 

Also Eileen has been someone who I would turn to for business advice and even personal advice. She would even pick up the phone at 2am when I was complaining about “the girl” or when a group of RDs would call (in a drunken stupor) from Cairo, Casablanca or Kuala Lumpur.

 

Eileen I will miss you and I wish you the best.

 

PS-people usually have to think really hard to figure out my titles most of the time, but this title was one of those “you had to be there ones” in Dallas at Tech*ED in 2003, a bunch of RDs (led by me!) got on stage and did “Killing me Softly” Karaoke and dedicated it Eileen.

posted on Wednesday, December 1, 2004 12:52:06 PM (Eastern Standard Time, UTC-05:00)  #    Comments [12] Trackback
# Monday, November 29, 2004

On Saturday I reached the summit of the trail-less peak Fir Mountain. I am now only a few peaks away (4 peaks, 2 hikes) away from reaching membership to the Catskill 3500 Club.

The Catskill 3500 is a club where if you hiked the 35 peaks in the Catskill Range that are above 3500' in elevation. How do you get to 39 you ask? You have to do 4 of the peaks twice, in the winter time.

I should get in early next year! I have been working on them since February 2002. These hikes have been very rewarding and the views have been great!

Dad is nagging me to take him hiking in the Catskills, Slide Mountain on snowshoes will be the first peak I do after I get the other 4. Hope to see some of you there...

You climber snobs may say 3500' that’s it? To you I say become a member of the 3500 club and get back to me. :) Some of these climbs were just as challanging as any day on Kilimanjaro (except the last two days).

posted on Monday, November 29, 2004 11:49:00 AM (Eastern Standard Time, UTC-05:00)  #    Comments [18] Trackback
# Monday, November 22, 2004

The Departments of Transportation and Parks & Recreation announced a series of steps the City will take to increase recreational use of Central Park.

The DOT is going to close for good some entrances and implement carpooling, so there will be less cars to try to kill us. They did lower the speed limit to 25 mph, that will be hard to respect on the bike!

I hope the dream of a car-free Central Park becomes a reality! Rumor has it the city wants to do this...

This is a great step.

posted on Monday, November 22, 2004 11:43:02 AM (Eastern Standard Time, UTC-05:00)  #    Comments [19] Trackback
# Thursday, November 18, 2004

One of the great benefits of being an RD who speaks at conferences around the world is making friends all over. Usually my IM boxes open at any given time include at least someone from two or three different continents. While we all agree on development strategies and methodologies, we don’t always agree on politics. Friends can have a spirited discussion on sensitive topics and disagree-but remain friends. Here is an exchange between Boston RD Patrick Hynds, one of the smartest RD on the planet, myself (not so smart) and our friend in Egypt Mahmoud A. Gomaa.

 

Mahmound sent us a chilling graphic of a dead or injured Iraqi civilian.  Below is our exchange.

 

Mahmound writes:

 

From: Mahmoud A. Gomaa
Sent: Thursday, November 18, 2004 2:06 AM
To: Stephen Forte; Hynds, Patrick
Subject: Falluja
Importance: High

this photo attached, is for an Iraqi civilian, killed while he was carrying his daughter, running from the wild attack of American troops in their compain againest terrorism!!!!!!!!!!!.

wondering where it is

 

Patrick writes back very eloquently:

 

From: Hynds, Patrick 
Sent: Thursday, November 18, 2004 9:37 AM
To: Mahmoud@ieee.org; Stephen Forte
Subject: RE: Falluja

 

Mahmoud,

 

No one likes the consequences of war, unless they are insane.  I regret what is happening in Iraq and what is happening in places torn by war without US involvement.

 

I am of Irish decent and I view what is happening in Iraq as very similar to what happened for decades in Northern Ireland.  The British came in under circumstances that they thought were correct and hoped to only stay for a short duration.  The actions of the Catholic terrorists of the IRA (yes I am catholic and yes they were terrorists) kept the British troops there for most of the century.  Many civilians were killed by actions on both sides, but most often I blamed the IRA insurgents (my own people).  Luckily that mess is mostly over.  Now Iraqi fighters get to decide if they want to keep American troops for a century or not.  There is not enough oil in Iraq to pay for our being there for another 10 years.  If we took all the oil Iraq produces for 10 years without paying a dollar it would not pay for the American costs of the war up to this point. 

 

I have fought a war as an infantry soldier.  I still feel horrible guilt for the soldiers I have killed knowing full well that they would have killed me had I acted less swiftly.  I have seen our military prosecute offenses (and our troops are only human so they do occur) more rigorously than any other military in the world.  I hate to see this kind of thing, but I honestly blame the insurgents for the vast majority of the death of the innocents.  I also have seen for myself the atrocities committed by Saddam while I was in the first gulf war.

 

The attacks on New York and Washington in 2001 have changed many goals and perspectives of the US government and of most of its people.  When the Japanese attacked us at Pearl Harbor they awoke a sleeping giant.  Bin Laden has done it again and the consequences have and will continue to be long reaching.  I understand that much of the world (Arab and non-Arab) are upset by US tinkering in the middle east especially support for Israel and the first Gulf War.  I have no illusions that there is a single country in the world that would not be forcing their will around the world if they had the ability to do so.

 

I don't blame all Egyptians, Jordanians or Saudis for the attacks on the World Trade Center.  I don't blame all Iraqis for the deaths of my friends and classmates who are serving in the US military in Iraq.  I don't expect to be blamed for every crime committed by a US soldier, especially when he will be put on trial and imprisoned if found guilty.

 

Lastly, while the picture you sent is very powerful and dramatically sad and you can by association conclude that they died as a result of the US invasion of Iraq, there is really no way to conclude that an American actually killed them. 

 

I didn't send you a link to the story about the terrorists in Iraq who just killed Margaret Hassan.  Margaret was an Irish woman married to an Iraqi man who by all accounts did more for the people of Iraq in the last 20 years then a thousand of these insurgents are likely to do.  I realize that frustration in the rest of the world especially Egypt and other neighbors of Iraq is very high.  I actually don't mind this kind of conversation so long as you don't take offense to my having a response and likely a different world view.

 

I hope my response does not chill our relationship as I have felt that over the last year, we have had a good camaraderie as fellow developers.

 

Thanks
Patrick

 

Patrick J. Hynds
CTO, CriticalSites
Microsoft Regional Director, MCSE+I, MCSD, MCDBA, MCP+Site Builder, MCSA, MCT

posted on Thursday, November 18, 2004 10:31:19 AM (Eastern Standard Time, UTC-05:00)  #    Comments [5] Trackback
# Monday, November 15, 2004

2004 will be remembered for many things. History will show us that it is the year the entertainment industry went to the wall in an all-out bid to wipe out internet file sharing. It will also mark the beginning of the end for the RIAA and MPAA.

 

The very evil RIAA (Recording Industry Association of America) has been hammering file sharers since September, 2003, and has so far sued 6,191 people. Learning from their comrades in arms,  the Wall Street Journal recently reported that the equally evil MPAA (Motion Picture Association of America) has just mounted its own RIAA-style sue 'em all attack.

 

The entertainment industry finds it highly cost effective to sue normal people (like old ladies and students) with no financial or legal resources. They have no choice but to accept the entertainment industry's offer to 'settle'. (Where is David Bois now?)

 

Now, instead of running separate actions, the RIAA and MPAA will merge their resources and staffs to become the World Recording and Motion Picture Industry Association (WRAMPIA, pronounced 'wrampia').

 

Look at iTunes and MSN Music and the newest formation of Napster. THAT is a business model. Why did the RIAA reject this business model in the late 1990s? Now they are afraid of being left out and exposed for the expensive middle men that they are.

 

The movies are afraid that now with broadband the same thing will happen to them. They can’t fight the technology so they decided to merge. The last act of desperation by dying industry trade organizations.

 

Instead of suing your customers, figure out a way to make money with file sharing. It is easy. Apple figured it out. Microsoft figured it out. Napster figured it out. But you are too greedy.

 

posted on Monday, November 15, 2004 12:37:29 PM (Eastern Standard Time, UTC-05:00)  #    Comments [17] Trackback
# Wednesday, November 10, 2004

Mt. Rainier had a 3.2 earthquake yesterday-one mile below the surface of the crater. Mt. St. Helens had a similar earthquake before is started to spew last month, but scientists say the two events are not linked. But five quakes greater than magnitude 2.0 were recorded Oct. 25-31-the same kind of activity on Mt. St. Helens.

I am just glad that I got to the top of Rainier this summer since if it goes, it will go big. I think it may go soon, it has been waiting 150 years. You heard it here first....

More bad news from this climbing season. The 7th person died on Mt. Rainier this year on October 25th. What is worse is that this is the first person do die this season on the Camp Muir side of the mountain. Two locals were hiking across a crevasse on Ingraham Glacier, 11,000 feet up the 14,411-foot mountain, near Disappointment Cleaver, when an avalanche hit. One guy had only his had free and dug himself to safety, but could not help his buddy at all. I camped at Ingraham Glacier at the foot of Disappointment Cleaver. :(

posted on Wednesday, November 10, 2004 11:40:20 AM (Eastern Standard Time, UTC-05:00)  #    Comments [10] Trackback