Showing posts with label horizontal result set. Show all posts
Showing posts with label horizontal result set. Show all posts

Thursday, 24 June 2010

Wicket - Programattically Scroll a Div Horizontally

I came across a user case where I had to programatically scroll the contents of a div to the right. This was
to be performed on a click of an ajax link. This is how I achieved the same:

onSubmit(AjaxTarget....)
{
.... body of onsubmit , additional operations.
target.appendJavascript("var obj = document.getElementById('divid');obj.scrollLeft = 500;");
}


some additional methods which could be used on the window itself rather than a div are

scrollBy
scrollTo
moveBy

Monday, 18 May 2009

SQL Server PIVOT - Magic isn't it

Ever wonders how you could present data via a select statement horizontally instead of vertically. When your columns come from the data you are retrieving from the select statement. The answer is simple in TSQL called the pivot keyword. All it would do is to use the data as the pivot to form the columns. Consider the simple schema of the employee: Product
  • Name
  • ID
Product Sales
  • ID
  • Agent ID
  • Quantity
Agent
  • Name
  • ID
And lets say you want a result table which shows: Agent product year select a.name as 'Agent', p.name as "" from agent a inner join product_Sales pd on ps.agent_id=a.id inner join product p on p.id=ps.product_id PIVOT (SUM(Quantity) for Agent IN (Agent1, Agent2, Agent3)) AS pvt