Here is the sql query to do the running total for salary column from employee table
--Running Total Salary
SELECT
EMPLOYEE_ID,
FIRST_NAME,
SALARY,
SUM(SALARY) OVER (ORDER BY FIRST_NAME
RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) Running_Total
FROM
EMPLOYEES
ORDER BY
FIRST_NAME
--Running Total Salary by department
SELECT
DEPARTMENT_ID,
FIRST_NAME,
SALARY,
SUM(SALARY) OVER (PARTITION BY DEPARTMENT_ID
ORDER BY DEPARTMENT_ID, FIRST_NAME) RUNNIG_TOTAL_BY_DEPT
FROM
EMPLOYEES
--Running Total Salary by department name
SELECT
DEPARTMENT_NAME,
FIRST_NAME,
SALARY,
SUM(SALARY) OVER (PARTITION BY DEPARTMENT_NAME
ORDER BY DEPARTMENT_NAME, FIRST_NAME) RUNNIG_TOTAL_BY_DEPT
FROM
EMPLOYEES, DEPARTMENTS
WHERE
EMPLOYEES.DEPARTMENT_ID = DEPARTMENTS.DEPARTMENT_ID
ORDER BY
DEPARTMENT_NAME,
FIRST_NAME
Friday, January 2, 2015
Setting date format in Telerik RadGrid column cell
You can set the date format by using the below code snippet in ItemDataBound event in telerik radgrid control
Here is a sample c# code for MM/dd/yyyy format
protected void rgDisplay_ItemDataBound(object sender, GridItemEventArgs e)
{
string strDateFormat = "MM/dd/yyyy";
if (e.Item.ItemType == GridItemType.Item ||
e.Item.ItemType == GridItemType.AlternatingItem)
{
GridDataItem gdItem = (GridDataItem)e.Item;
DateTime result;
string dateVal = DataBinder.Eval(gdItem.DataItem, "BindDateColName").ToString();
if (DateTime.TryParse(dateVal, out result))
{
gdItem["uniqueNameDateCol"].Text = result.ToString(strDateFormat);
}
}
}
Here is a sample c# code for MM/dd/yyyy format
protected void rgDisplay_ItemDataBound(object sender, GridItemEventArgs e)
{
string strDateFormat = "MM/dd/yyyy";
if (e.Item.ItemType == GridItemType.Item ||
e.Item.ItemType == GridItemType.AlternatingItem)
{
GridDataItem gdItem = (GridDataItem)e.Item;
DateTime result;
string dateVal = DataBinder.Eval(gdItem.DataItem, "BindDateColName").ToString();
if (DateTime.TryParse(dateVal, out result))
{
gdItem["uniqueNameDateCol"].Text = result.ToString(strDateFormat);
}
}
}
Subscribe to:
Posts (Atom)