I recall a few years back while I was still working towards my degree of Computer Science and Engineering, without a superior GPA and without a clear path of a career, I seeked advice from an older friend who had been in the working world for a few years. His answer was quite straight forward, "Go be a consultant." he said. Without too much knowledge in the consulting world, and with my mindset of being a software developer, I quickly brushed off the advice.
Recently I recalled this conversation out of the blue and by that time I was an IT Consultant having worked in the field for 5 years already, and I am enjoying it.
So what is a difference between a developer and a consultant?
In short, developers solve a technological challenge, while an IT consultant solves a business challenge using technlogy.
During my career I have worked with developers and consultants, sometimes even worked with consultants who really should have been a developer or vice versa. I think the biggest difference lies in the following points.
Understanding of the subject knowledge:
Most technologies works independent of industry, one can make a website with .NET MVC for an online store or for a stock exchange broker. So as a developer working for Microsoft to come out with a technology (in this case MVC) which helps web developers to make a website, not much subject knowledge is required.
However, as a consultant who sits with an online store owner trying to figure out what features should be included in the online store, subject knowledge would be necessary. A basic understanding of the business, customers, would be needed in order to design a website that suits the need of the client. The subject knowledge is not always required, but if a picky client is paying for a consultant to get things done, they are looking for exactly this.
Communication skills requirement
A developer usually works in-house and is in charge of code. Most often they report to the lead developer or the software architect. No matter if it is a lead developer or software architect, their understanding of technology subject is usually higher than the developer himself and thus a developer rarely have to worry about the word choice, the technology specific terms will be understood.
Consultants usually works at the client site and often needs to communicate with the client regarding needs and wants. Most often the client is a businessman who doesn't have a clue how technology works. So it would be a bad idea to start bringing in terms like SQL, .NET, Dependency Injection etc. because to a businessman these terms are as familiary as greek. (No offence to Greece, but that's what I was told in my early years.)
Ability to bargain and be political
Developers gets a task list and the list needs to be completed by a certain deadline and usually that's the end of the story. It is not because there are no politics, but simply those are handled by people higher up in the heiarchy. A developer simply have to strive on making the best software, one that is robust, fast, and is flexible to additional features in the future.
Consultants often faces challenges outside of technology. For example, a budget constraint or a strategic decision which doesn't allow the consultant to implement the solution with the desired technology or method. Furthermore, the classical argument of what is a change request vs a bug also require a lot of energy/effort.
Summary:
The line between consultant and developer is getting blurry and thus it is more difficult to split between them. I am writing this to point out a few key difference so that students or job hunters can self-analyze thier strength and weaknesses in order to choose the job that fits them better.
Monday, February 13, 2012
Sunday, September 11, 2011
Recursive query with CTE
This is my first time writing a technical blogpost. Any comments are welcome.
CTE, Common Table Expressions can be considered to be a temporary table within a query (commonly used in a stored procedure or a function), one advantage of it is that it can refer to itself and thus makes recursive query possible.
example:
with SalesAmountByCustomer as
(
Select
CustomerID,
sum(SalesAmount) as SalesAmount
From
CustomerSales
Group By
CustomerID
)
Select
CustomerName,
SalesAmount
From
Customer
Join SalesAmountByCustomer on Customer.CustomerID = SalesAmountByCustomer.CustomerID
Order By
CustomerName
For those who understand the concept of recursion, there is always a base condition, and a parameter which the function takes and manipulate. While the base condition is not met, it will repeatedly call itself with the manipulated parameter and the function will keep manipulate the parameter until the base condition is met.
CTE acts the same way.
A CTE recursive query has the following structure:
with "CTE Name" as
(
"select statement that represent the first call"
Union ALL
"select statment which refers to the CTE, usually a join with the CTE itself"
)
The second part will eventually return no result (just like a recursive function will eventually have its base condition met).
Practical example:
Suppose we have an employee table that looks like this:
And to find out Cyclops superior and his/her superior and so forth, one can write the following query:
with Sup as
(
SELECT EmployeeID, Name, SuperiorID FROM Employee WHERE name = 'Cyclops'
UNION ALL
SELECT E.EmployeeID, E.Name, E.SuperiorID FROM Employee E JOIN Sup on Sup.SuperiorID = E.EmployeeID
)
Select Name from Sup
Another thing I did with recursive CTE was to generate a "Heirarchy" view for a dropdown list in my SSRS report.
Using the above table as example, the query would then become like this:
with list as
(
Select
cast(Name as varchar(max)) as Heirarchy,
'-' as Spacing,
EmployeeID,
Name,
SuperiorID
From
Employee
Where
Name = 'Professor X'
Union All
Select
cast(Parent.Heirarchy + Child.Name as varchar(max)) Heirarchy,
cast(' '+Parent.Spacing as varchar(max)) Spacing,
Child.EmployeeID,
Child.Name,
Child.SuperiorID
From
List as Parent
Join Employee as Child on Child.SuperiorID = Parent.EmployeeID
)
Select
Spacing + Name EmployeeName,
From
List
Order By
Heirarchy
The above code will produce the following result:
-Professor X
-Storm
-Wolverine
-Cyclops
CTE, Common Table Expressions can be considered to be a temporary table within a query (commonly used in a stored procedure or a function), one advantage of it is that it can refer to itself and thus makes recursive query possible.
example:
with SalesAmountByCustomer as
(
Select
CustomerID,
sum(SalesAmount) as SalesAmount
From
CustomerSales
Group By
CustomerID
)
Select
CustomerName,
SalesAmount
From
Customer
Join SalesAmountByCustomer on Customer.CustomerID = SalesAmountByCustomer.CustomerID
Order By
CustomerName
For those who understand the concept of recursion, there is always a base condition, and a parameter which the function takes and manipulate. While the base condition is not met, it will repeatedly call itself with the manipulated parameter and the function will keep manipulate the parameter until the base condition is met.
CTE acts the same way.
A CTE recursive query has the following structure:
with "CTE Name" as
(
"select statement that represent the first call"
Union ALL
"select statment which refers to the CTE, usually a join with the CTE itself"
)
The second part will eventually return no result (just like a recursive function will eventually have its base condition met).
Practical example:
Suppose we have an employee table that looks like this:
| EmployeeID | Username | Name | SuperiorID |
| 1 | x1234 | Professor X | null |
| 2 | s1234 | Storm | 1 |
| 3 | w1234 | Wolverine | 1 |
| 4 | c1234 | Cyclops | 3 |
And to find out Cyclops superior and his/her superior and so forth, one can write the following query:
with Sup as
(
SELECT EmployeeID, Name, SuperiorID FROM Employee WHERE name = 'Cyclops'
UNION ALL
SELECT E.EmployeeID, E.Name, E.SuperiorID FROM Employee E JOIN Sup on Sup.SuperiorID = E.EmployeeID
)
Select Name from Sup
Another thing I did with recursive CTE was to generate a "Heirarchy" view for a dropdown list in my SSRS report.
Using the above table as example, the query would then become like this:
with list as
(
Select
cast(Name as varchar(max)) as Heirarchy,
'-' as Spacing,
EmployeeID,
Name,
SuperiorID
From
Employee
Where
Name = 'Professor X'
Union All
Select
cast(Parent.Heirarchy + Child.Name as varchar(max)) Heirarchy,
cast(' '+Parent.Spacing as varchar(max)) Spacing,
Child.EmployeeID,
Child.Name,
Child.SuperiorID
From
List as Parent
Join Employee as Child on Child.SuperiorID = Parent.EmployeeID
)
Select
Spacing + Name EmployeeName,
From
List
Order By
Heirarchy
The above code will produce the following result:
-Professor X
-Storm
-Wolverine
-Cyclops
Subscribe to:
Posts (Atom)