SQL Server :: Counting And Dividing In A Query?

Dec 16, 2010

I need to count some results and divide it to another. My problem is that it´s only the outer table that is grouping on datepart, wd. Since I´m wanting to display some results per week the counting should be done per each week .

If I´m running the query below the dividings are the totals against datepart (week). I want to divide the datepart, wk internally, week by week.

SELECT datepart(wk, entry_date),
CAST(
count(*)*1.0/
(select count(*) from agent_input where
substring(campaign,1,3) in ('srk', 'bbk', 'spz', 'mbk', 'lyk') )
as DECIMAL (5,4))
*100 as mailprocent
FROM agent_input
where substring(campaign,1,3) in ('srk', 'bbk', 'spz', 'mbk', 'lyk') and agent_input23 is not null
group by datepart(wk, entry_date)

View 7 Replies


Similar Messages:

Access :: SQL - Dividing The Count Of 2 Records?

Aug 24, 2010

I have a problem that I cannot seem to resolve. We are using an access database to store data from a Quality Assurance Tool. I need to calculate an average on a specific column in the table, however the SQL statement needs to count the number of records that contain "0.1" and divide it by the total number of records in the table. This data is then displayed in an ASP Page.

The field name is 1.

Here is the SQL:

StrSQL = "(Select Count([1]) FROM cservice Where [1]=0.1) / (Select Count([1]) FROM cservice) As questaverage "

View 3 Replies

Forms Data Controls :: Donut Chart Counter Clockwise And Starts Dividing The Donut From 90 Degrees?

Jan 20, 2011

I have created a donut chart using ASP.NET chart control.The pies/sections are ordered in clockwise direction but I need them to be ordered in anti clockwise direction.I know that I can add the values in reverse order and achieve this but there must be a solution to this.

Also, it starts dividing the donut from 90 degrees to the right but I want it to start right from the top of the donut i.e. 0 degrees.

View 1 Replies

DataSource Controls :: Can't Find Query's / By Right Clicking On Database Created A Query In Server Explorer?

May 17, 2010

By right clicking on my database i created a query in server explorer. But where are this query stored can't find them back. I should aspect that their is a folder query's like there is a folder tables but this isn't the case.

View 10 Replies

SQL Server :: Sub Query In Cross Table Query To Create Statistics

Mar 2, 2011

I am trying to create statitics for game downloads and am having dificulty with a sub part of my query. the goup by command is not having the disired result and i think i have been looking at it too long to see what i am doing wrong. [Code]....

At the moment it is producing each result in many rows when only 4 rows should appear. its the download column that is doing it. needs to be sub queried or something to display total in relation to month,gameid,userid.

Month-download-GameID-UserID

1 1
1 1

1 1
1 1

View 2 Replies

SQL Server :: Query Slow In Loading / Trying To Display Query Result?

Feb 1, 2011

I am trying to display this query result in an aspx page.

It is very slow in loading. Here is the query. The inner query inside the outer quesry is the problem.(Please see the underlined part in the query) - (If I remove that part it is very fast.)

select

top 500

--This column is the issue
,Governing_Class=( case when exists (select top 1 tqc.class_code from
t_quote_class tqc
inner join t_quote_class_premium tqcm on tqc.class_code =tqcm.
class_code
where tqc.appid=pi.appid and tqc.class_code not in('8742' ,'8810','7380')
order by tqcm.premium_amt desc
)
then ( select top 1 tqc.class_code from
t_quote_class tqc
inner join t_quote_class_premium tqcm on tqc.class_code =tqcm.
class_code
where tqc.appid=pi.
appid
order by tqcm.premium_amt desc
)
......... From tables

View 7 Replies

Databases :: Oracle Query Convert To Sql Server Query

Sep 3, 2010

I am a biggner in SQL DB . but i started a complicated and painfull work in SQL SERVER 2008. the problem convert Oracle hierarchical query to SQL query. the query

SELECT DISTINCT
LEVEL LVL,
SCH.NSCHEDULE_SL,
SCH.NSCHEDULE_SL_FM,
SCH.CSHED_CNAME
FROM FA_SCHEDULES SCH
WHERE LEVEL = 1
AND NSCHEDULE_SL_FM IS NULL
AND NBRANCH_SL = 2
CONNECT BY PRIOR SCH.NSCHEDULE_SL_FM = SCH.NSCHEDULE_SL
AND NBRANCH_SL = 2

View 1 Replies

SQL Server :: How To Copy Result Query To Another Query

Nov 4, 2010

i have tow query in one stored procedure

first query and the second one every of them return only value

i want to copy the result of tow values in a new row in new table

as i want to check on this tow values in ado.net

i want to get only this tow values as a row not first and secon query

only a row has result of first and second query results

[Code]....

View 3 Replies

SQL Server :: Select Second Query If First Query Returns Nothing?

Oct 14, 2010

How can I SELECT second if first SELECT returns nothing?

View 8 Replies

SQL Server :: Get All Rows From Query A That Are Not In Query B?

Dec 17, 2010

Using sql server 2005.

I have an Query A of fields that returns X number of records.

I create a Query B of same fields that returns X-80 number of records.

I want to find out the 80 records that are in Query A but are not in Query B. what is the syntax for this?

View 4 Replies

SQL Server :: Trying To Get A Query Going In SQL Server But Get Bad/ Errors In The Query?

Nov 8, 2010

Trying to get a query going in SQL server but I get bad/ errors in the query.I have a 2 tables. One is the "Project" table while the other is the "Task" table.Table structure is as follows.

Project table => ProjectID,ProjectName
Task table => TaskID, TaskName,ProjectID,Quarter, Hours

A project can have many task. The ProjectID in Task table is the foreign key which reference the project ID.What I need to do is to SUM all the hours in the Task table and group it by quarter and then group it by ProjectID. Output of the SQL should be in the form of projectID,Quarter, Hours.

View 2 Replies

How To Add <br> In String After Counting Particular Characters

Jan 25, 2011

I want to display description of product in gridview, but i want to display only 15 characters on one line, I want to break it after 15 characters, I have written countchar function as follows:

public int CountChars(string value)
{
bool lastWasSpace = false;
foreach (char c in value)
{
result++;
lastWasSpace = false;
}
return result;
}

and called function as:

string description="sdfsdfsd sdfsdf sdfsdf asdfsa dfsda safsaf sdfdf sdfs sdfsdf sdff sdf ";

CountChars(description);

And i want to check:

if(result>15)
{
after every 15 characters i want to break the line.
}

View 3 Replies

Web Forms :: Counting Files In Folder In C#?

Jan 21, 2011

how to get the count of the number of files, if the file already exists in folder in C#.

View 2 Replies

Counting How Many Time A Button Have Been Clicked?

Apr 20, 2010

how many time i have clicked a single button like when a button is clicked three time i will redirect to another page the button is in an update panel and im using c#

View 2 Replies

Counting Number Of Objects In Arraylist?

Jan 2, 2011

I have a gridview where there is a column of checkboxes for the user to check on for the products he/she wants. After checking, they will have to click on a button. for every checkbox that is checked, the result will be stored in an arraylist. after the button is clicked, the label will show the count of the number of objects in the arraylist, which is the number of items that were checked. However, it appears that objects are not being added to the arraylist. What's the problem? Below is some portion of the code for more understanding.

[Code]....

View 4 Replies

Web Forms :: Counting Input Values 2

Oct 28, 2013

i have been trying two types of examples 

var counter = 0;
for (i=1; i<=9; i++) {
if (this.getField("JobPerReview36." + i).value=="1") counter++;
}

if (counter>0) {
event.value = counter;
} else event.value = "";

View 1 Replies

Web Forms :: Counting Fields As Integers

Oct 30, 2013

I have 4 drop down menus labeled as with static input as

0-9; JobPerReview1 JobPerReview2 JobPerReview3 JobPerReview4

If for choice the user selects the following;

JobPerReview1 = 3JobPerReview2 = 0JobPerReview3 = 5JobPerReview4 = 9

I would like a function/ script to sum the total inputs as an integer or if that's the correct term for it. So it would calculate something like thisJob

PerReview1 = 3 summed as 1JobPerReview2 = 0 summed as noneJobPerReview3 = 5 summed as 1JobPerReview4 = 9 summed as 1

I would also like a total box labeled "NOF (number of factors)to calculate the selections such as;

NOF = 3

This is starting to be mind bugling function

getItems(){var items = new Array();var itemCount = document.getElementsByClassName("items");
var total = 0;var id= '';for(var i = 0; i < itemCount.length; i++){id = "p"+(i+1);total = total + parseInt(document.getElementById(id).value);
} document.getElementById('tot').value = total;return total;
} getItems();
function getItems() {
var items = new Array();

[Code]....

View 1 Replies

Web Forms :: Want To Add Counting Number To Radiobuttonlist Items / How To Do That

Feb 18, 2011

I want to add counting number to radiobuttonlist items, the radiobuttonlist is databounded.

protected void rptQuestion_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
RadioButtonList rbl = e.Item.FindControl("rblAnswer") as RadioButtonList;
rbl.DataTextField ="AnswerText";
rbl.DataValueField = "AnswerID";
rbl.DataSource = BindAnswer(questionid);
rbl.DataBind();
}

View 1 Replies

Counting Rows In C# After Dynamically Adding Them With JQuery

Dec 15, 2010

I just have a simple ASP Table seen here:

<asp:Table ID="tblCategories" runat="server" CssClass="oneColTable padded-table dataTable">
<asp:TableHeaderRow CssClass="tableHeader">
<asp:TableHeaderCell>Category Name</asp:TableHeaderCell>
<asp:TableHeaderCell Width="50">Delete</asp:TableHeaderCell>
</asp:TableHeaderRow>
</asp:Table>

And if the user wants to add an additional row I use the jQuery Clone method to copy and append a new row.

My issue comes when I want to count the rows present on the C# side it always lists 1 Row. The row for the header entry.

How can I correctly grab the accurate row count on the C# (Codebehind) side?

View 3 Replies

DataSource Controls :: Counting Records From A Database?

Jun 26, 2010

New to all this and trying to work out the best of doing what I need to do.

I have a little ddl with a list of 100 or so different items in it. The person clicks the button and it gets logged into a table (ItemLog).

So then where I become unstuck is I want:

A total number of records.A total number of records for each of the items in big long list.Then be able to break the records down by date.... Would I need to write out a lot of count statements in sql?

View 4 Replies

Access :: Counter Not Counting On Image Click In IE?

Dec 9, 2010

When you click the following in 'Chrome' it goes to the URL and adds 1 to the counter, yet when you do the same in 'IE' it goes to the URL but doesn't add one to the counter?

File Code =

<asp:ImageButton ID="ImageButton3" runat="server" Width="300" Height="213" onclick="ImageButton3_Click" imageurl="../images/actiw_banner.gif" PostBackUrl="http://www.actiw.com" OnClientClick="aspnetForm.target='_blank'"/>

Code behind =

protected void ImageButton3_Click(object sender, ImageClickEventArgs e)

View 4 Replies

AJAX :: Display Counting Using Update Panel?

Feb 24, 2011

I want to display count from 1 to 10 using a loop and update panel.Count change should be visible in browser.Just like currently processsing item is 1..then 2 and so On.

View 10 Replies

Web Forms :: Counting The Checkboxs And Checkboxlixt Validation?

Jan 13, 2010

I have the following simple logic on my buttionclick. Along with this, I need to implement my checkboxlist validation and need to find if more than one boxes are checked.

I attemtpted diffferent things by goggling, nothing worked. I would appriciate your help.

protected void Button1_Click(object sender, EventArgs e)
{
foreach (ListItem item in CheckBoxList1.Items)
{
if (item.Selected)
{
//item.Text and item.Value will give you other properties...
if (item.Text == "CSG")
{
Response.Redirect("page2.aspx");
}
if (item.Text == "GGSN")
{
Response.Redirect("page3.aspx");
}
}
}
}

View 16 Replies

C# - Counting Online Number Of Users Of A Web Application?

Jul 18, 2010

I am using ASP.Net + .Net 3.5 + VSTS 2008 + IIS 7.0 + C# to develop a web application. I want to count how many users are online. This is my current implementation,when Session_Start is called, I will increase # of users online by 1;when Session_End is called, I will descrease # of users online by 1.Two quesitons,A Is that implementaiton correct?B. Another question is, I think this method can not track # of users of real time, since when user closes the browser, Session_End will not be called immediately (Session_End will be deferred to be called). Correct?

View 3 Replies

Architecture :: Counting The Number Of Sessions In A Webform?

Oct 8, 2010

We have a ASP .NET application which will be deployed in a web farm. We would like to find the total number of sessions that have been established. If we create a counter in global.asax.cs, it will be able to count only within aspnet_wp process. In a web farm, multiple nodes will have IIS on multiple machines. If we use SQL server-based session management, can we get the total number of active session by querying the Session DB? If we later decide to use session state server to store the sessions, can we get the number of active sessions?

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved