Percentage Of Totals

Nov 14, 2006

I am relatively new to SQL i.e. I know the basics!

What I am trying to do is: I have a database of customer spend and I am trying to segment them into certain %ages of the search results. So, for example, find all of the customers that are in the top 10% of spenders (I also want to only select customers with a spend of greater than x!). I am trying to do this using a Case When but feel that I may be out of my depth.

Please help if you can!!

Thanks, Kris

View 4 Replies


ADVERTISEMENT

Reporting Services :: Calculating Grand Totals From Group Totals

May 9, 2015

I have some data grouped in a table by a certain criteria, and for each group it is computed a subtotal for the group. Of the values from each of the group, I want to create a grand total on the report by adding every subtotal from each group.

Example:
...
....
Group1              Value
                           10
                            20
Sub Total 1:         30

Group2                 Value
                              15
                              25
Sub Total 2:           40

Now, I would like to be able to add subtotal 1 (30) to subtotal 2 (40) and my grand total would be 70. Can I accomplish this task in SSRS?

View 5 Replies View Related

Trying To Get Daily Totals From Cumulative Totals In A Pivot

Oct 2, 2006

I have been providing sales data for a few months now from a table that is set up like this:

Date WorkDay GasSales EquipmentSales

9/1/2006 1 100.00 200.00

9/4/2006 2 50.00 45.00

etc.

As can be seen, the data is daily, i.e., on the first workday of September we sold one hundred dollars in gas and two hundred dollars in equipment. On the second workday of September we sold fifty dollars in gas and forty-five dollars in equipment.

Now, however, the data I have to pull from is cumulative. So, using the last table as an example it would look like this:

Date_WorkDay_GasSales_EquipmentSales

9/1/2006 1 100.00 200.00

9/4/2006 2 150.00 245.00

etc.

To make things more complicated, the powers that be wanted this data presented in this fashion:

Total Sales:

1_2_etc.

300.00 95.00 etc.

 So, I have been doing a pivot on a CRT to get the data to look like I want. The code is like this:

with SalesCTE (Month, WorkDay, [Total Sales])

as

(

SELECT

datename(month, cag.date),

cag.WorkDay AS [Work Day],

sum(cag.sales_gas + cag.sales_hgs) AS [Total Sales]

FROM CAG INNER JOIN

Branch ON CAG.[Oracle Branch] = Branch.OracleBranch

group by cag.date, cag.WorkDay

)

select * from SalesCTE

pivot

(

sum([Total Sales])

for WorkDay

in ([1],[2],[3],[4],[5],,[7],,[9],[10],[11],[12],[13],[14],[15],[16],[17],[18],[19],[20],[21],[22],[23])

) as p

So, my question is:

How do I get the data to give back daily totals instead of the cumulative amounts for each workday? If the query was a simple one, I'd do something like

select [1] as [Day 1], [2]-[1] as [Day 2], [3]-[2] as [Day 3], etc.

but the query is far from normal, with the CRT and the pivot. I can't seem to get it to work how I'd like.

Any advice/answers? Thanks in advance!!!

 

P.S. I don't know how to get it to quit with the freakin' smileys.... I suppose you can figure out what my code is really supposed to look like above. Needless to say, it doesn't include a devil face and a damn music note...

View 12 Replies View Related

Percentage

Mar 1, 2004

Hello
I need a little help.
I'm working on this query but is not returning the value I want

SELECT CONVERT(float, hits)/ abat as 'AVE'

The hit column value is 3 and abat 4 I want to return 750 but so far I'm getting
.75 or if I try decimal returns .7500000000

Thanks
Robert

View 2 Replies View Related

Percentage Help

May 26, 2006

I need to write a page that figures out the percentage of students passing an assessment item where students are from a particular school, grade, gender, and are not medically exempt.
I did a Count Statement on all test taker, and another Count Statement for the number passing the item who were not exempt.  Both of the statements are shown through seperate datalist controls.  I then want to get the percentage by dividing the number passed by the number taken and mulitplying that by 100. 
Is there a better technique or can I do this in a sql statement somehow?

View 1 Replies View Related

How Can I Get The Percentage ?

Mar 18, 2008

I am havingSELECT DISTINCT Name, (( count(id_Name) * 100 ) / (SELECT count(id_Name) AS tt FROM dbo.Name)) as PercentageFROM dbo.NameGROUP BY Namebut I get only integers : 1,0,4,12I need : 1.63, 0.4, 4.05, 12.78how can I do it ?is there a better way to calculate a percentage ?thank you

View 5 Replies View Related

Help With Percentage

Jun 3, 2008

Hi i create a temp table that count how many A,B,C and D there where in a table.

I need calculate the percentage.It could be easy put the problem is that i cannot devide by the same number.

Here my temp table DECLARE @Temp table
(
strLastName varchar(50),
strFirstName varchar(50),
strReponse char(10),
strNomObjet nvarchar(200),
strDescripteurOrdre char(10),
strNomDescripteur nvarchar(200),
strObjetOrdre char(10)
)

I want to check how many A there is.

SELECT strNomObjet,strNomDescripteur,count(*) FROM @Temp
WHERE strReponse = 'A'
GROUP BY strNomObjet,strNomDescripteur

This will give me somthing like this
For the first one there 25 A
Second 27 A

NOMBRE ET OPÉRATIONSdémontre une compréhension du concept du nombre25
NOMBRE ET OPÉRATIONSpeut faire les opérations sur les nombres pour résoudre des problèmes27
STATISTIQUES ET PROBABILITÉSpeut suivre les étapes d'une démarche statistique26
RÉGULARITÉS ET RELATIONSutilise des régularités (suites logiques) pour résoudre des problèmes24
RÉGULARITÉS ET RELATIONSutilise des relations mathématiques (algèbre) pour résoudre des problèmes23
FORMES ET ESPACE (géométrie)utilise la mesure pour résoudre des problèmes17
FORMES ET ESPACE (géométrie)utilise les figures géométriques pour résoudre des problèmes22
STATISTIQUES ET PROBABILITÉSutilise les probabilités pour résoudre des problèmes27
FORMES ET ESPACE (géométrie)utilise les transformations géométriques pour résoudre des problèmes22

After that i use


SELECT count(*) FROM @Temp
GROUP BY strNomObjet,strNomDescripteur

That will give me how many person have been tested.

It will give me this
36
36
35
36
35
36
36
35
35


So i need to take the first 25

25 / 36 * 100 = 69.4%
27 / 36 * 100 = 75%
26 / 35 * 100 = 74.2%


I hope you understand what i mean!
Any idea?
Tks in advance

View 8 Replies View Related

Top N Percentage

Jul 23, 2005

Hello!I have a need to create a function that will return a sublist ofelements from a table based on an associated column value and itsranking within the table (based on a percentage range).To expand with a simple example (only 4 elements):Element | Value---------------A102 | 5A506 | 10A322 | 15A342 | 20I would like to be able to return the range of elements that lie in the50-75% value range (e.g. third quartile range). Therefore with onlythese four elements I would want to return the element code 'A322'.I have attempted to achieve this by using SELECT TOP n PERCENT. I canbring back the required range by combining two select percentstatements.SELECT Element from ELEMENT_TABLEWHERE Element IN(SELECT TOP 75 PERCENT Element FROM ELEMENT_TABLE ORDER BY Value)AND Element NOT IN(SELECT TOP 50 PERCENT Element FROM ELEMENT_TABLE ORDER BY Value)The problem is that I cannot seem to pass a variable to this percentageso if I want another percentage range set, I ave to define anotherfunction.My question therefore is does anyone know either(1) a way I can pass a variable (n) to these SELECT n PERCENTstatementsOR(2) an alternative way of doing this?Many thanks!Andrew

View 3 Replies View Related

Percentage

Mar 11, 2008

Hi team, I have a column 'a' of a table in which i would like to calculate a percentge of all entries in that column 'a' and place the results in a column 'c' beside column 'a'. Can this be done in sql server ??

View 5 Replies View Related

What Percentage Of The Row Has Data

Sep 13, 2006

Lets say I have a table called ProductProductId Name Price Category1             Table  20.00  Furniture2             Chair3             Lamp            Misc What is the SQL command that would give me as a percentage the completeness of a row, either complete or empty?For e.g. SELECT ... FROM Product WHERE ProductId = 2 ; should give a result of 50% as half the Columns in that row are empty.e.g. SELECT ... FROM Product WHERE ProductId = 3 ; should give a result of 25% as 1/4 of the Columns in that row are empty.I tried used something like SELECT     COUNT(COLUMN_NAME) AS Expr1FROM         INFORMATION_SCHEMA.COLUMNSWHERE     (TABLE_NAME = 'Product')but dont know how to go forward.

View 2 Replies View Related

SQL Query To Get A Percentage

Mar 11, 2008

Ok guys, here is my query
GridSqlDataSource1.SelectCommand = "SELECT *, (([WinSum])/(([WinSum]) + ([LossSum]))) AS WinPercent FROM [ResultsView] WHERE ([CDIV] = @CDIV) ORDER BY [CTEAM]"
I need it to give me a 3 decimal percentage for WinPercent, but right now it is giving me 0 because as an example:
6 / 7 = 0 instead of 0.857
Any ideas?

View 10 Replies View Related

SQL Calculate Percentage

May 6, 2008

Hello every one, I am trying to get the total percentage of a column









Regions
Workbooks Required
Workbooks Sent 
Workbooks Returned
Workbooks Complete

A
20
21
20
18

B
33
33
33
30

C
19
29
18
16

D
9
18
8
8

Totals




Thanks in advance for any tips/solutions.

View 5 Replies View Related

Percentage Query

Aug 5, 2007

Hi Guys,

I am in need some uinderstanding of how to return the percentage of calls that were closed, between 1, 2 ,3, 4 and 5 days (possibly extendable to catch all those that were holding on to jobs to make it look like the were busy) as well as including all open jobs.

Because of my newbie status I am stumped at how to even start a query of this magnitude, and no this is not a school assignment :-) just some one who is very new to T-SQL and wanting to learn how to extract data from an MS SQL database server, as I find it fascinating, also my bosses find it fascinating the type of data I am returning for them so far.

So enough waffling.

This query will be run through VBA, any variable(s) will be supplied by VBA.

DB name = Envisage
Table name = HD_Call
Columns = DateRaised (datetime, null), DateCompleted (datetime, null)


Help in understanding how to construct this query will be grately appreciated.

View 13 Replies View Related

Percentage Measure

Sep 14, 2004

Hi,

easy question for advanced users:

I have a dimension called "Movement rate". The members are "1" to "6".
There is a measure called "No. of Products".

What i easily like to do is showing the percentages "No. of Product" for each "Movement rate" of the amount of "No. of Products" without using the frontend-tool.

Thx in advance for any help.

Andreas

View 2 Replies View Related

How To Calculate Percentage

Apr 28, 2004

b/w two colums?

i have two numberic columns
i want percentage of column2/column1
They are on separate table.. l am intended to creat view with my results.
thanks

View 8 Replies View Related

Calculate Percentage Value

Aug 29, 2013

I have requirement in which i need to calculate percentage value based on billamount and concession amount..to calculate the percentage part and show the o/p.

SELECT PP.KID_ID_NO_V,(PP.FIRSTNAME_V + SPACE(1) + PP.LASTNAME_V)AS [PATIENT_NAME],BM.TOTAL_AMOUNT_M AS [BILL_AMOUNT],BM.CONCESSION_AMOUNT_M AS [CONCESSION_AMOUNT],BM.BILL_AMOUNT_M AS [TOTAL_AMOUNT],
FROM BILL_MASTER BM
INNER JOIN PATIENT_PROFILE PP ON BM.PATIENT_ID_N=PP.PATIENT_ID_N
WHERE BM.BILL_SETTLED_C='Y'

[code]....

View 5 Replies View Related

Calculate Percentage In Sql

Dec 13, 2005

Hi, Please help.

I need to calculate percentage [COUNT(ALERT_RECEIVED_DATE) FRAUDCT,over SUM(CASE WHEN FRAUD_DECISION IS NULL THEN 1 ELSE 0 END) FRAUDUNWK] I tried my best but I cant come up with the solution.

Please, help.

Thk


SELECT
CONVERT(nvarchar(10),dateadd(d,-day(ALERT_RECEIVED_DATE) + 1,ALERT_RECEIVED_DATE),101) PERIOD,
COUNT(ALERT_RECEIVED_DATE) FRAUDCT,
SUM(CASE WHEN FRAUD_DECISION IS NULL THEN 1 ELSE 0 END) FRAUDUNWK,
SUM(CASE WHEN FRAUD_DECISION ='D' THEN 1 ELSE 0 END) DECLINED,
SUM(CASE WHEN A.FRAUDID IS NOT NULL AND FRAUD_DECISION IS NULL THEN 1 ELSE 0 END) PENDING_EXCEPTION,
SUM(CASE WHEN A.FRAUDID IS NOT NULL AND FRAUD_DECISION='D' THEN 1 ELSE 0 END) DECLINED_EXCEPTION
FROM
TBLFRAUDFINDER O

View 3 Replies View Related

Calculate Percentage In Sql

Dec 13, 2005

Hi, Please help.

I need to calculate percentage [COUNT(ALERT_RECEIVED_DATE) FRAUDCT,over SUM(CASE WHEN FRAUD_DECISION IS NULL THEN 1 ELSE 0 END) FRAUDUNWK] I tried my best but I cant come up with the solution.

Please, help.

Thk


SELECT
CONVERT(nvarchar(10),dateadd(d,-day(ALERT_RECEIVED_DATE) + 1,ALERT_RECEIVED_DATE),101) PERIOD,
COUNT(ALERT_RECEIVED_DATE) FRAUDCT,
SUM(CASE WHEN FRAUD_DECISION IS NULL THEN 1 ELSE 0 END) FRAUDUNWK,
SUM(CASE WHEN FRAUD_DECISION ='D' THEN 1 ELSE 0 END) DECLINED,
SUM(CASE WHEN A.FRAUDID IS NOT NULL AND FRAUD_DECISION IS NULL THEN 1 ELSE 0 END) PENDING_EXCEPTION,
SUM(CASE WHEN A.FRAUDID IS NOT NULL AND FRAUD_DECISION='D' THEN 1 ELSE 0 END) DECLINED_EXCEPTION
FROM
TBLFRAUDFINDER O

View 1 Replies View Related

Sum And Percentage In Query

Jun 26, 2007

I have following tables structure

Employee
---------
EMP_ID varchar PK
NAME varchar
DEPARTMENT_CODEvarchar
POSITION_CODEint

Position
--------
POSITION_CODEint PK
POSITION_NAMEvarchar

Department
----------
DEPARTMENT_CODEvarchar PK
DEPARTMENT_NAMEvarchar


Training_Module
---------------
TRA_ID varchar PK
TRA_NAMEvarchar
TRA_GROUPvarchar (three group, A,B and C)

View_Training_Module
--------------------
MV_ID int PK
EMP_ID varchar
TRA_ID varchar
VIEW_DATE datetime


Training_Module table data like this
TRA_ID..TRA_NAME..TRA_GROUP
--------------------------------------
v01SafetyVideo1G1
v02SafetyVideo2G1
v03SafetyVideo3G1
V04SafetyVideo4G2
V05SafetyVideo5G2
v06SafetyVideo6G2
v07SafetyVideo7G3
v08SafetyVideo8G3
v09SafetyVideo9G3


View_Training_Module table data like this
EMP_ID.........TRA_ID....VIEW_DATE
-------------------------------------------
p0006367V016/2/2007
p0006367V026/2/2007
p0006367V036/2/2007
p0003892V016/12/2007
p0003892V026/12/2007
p0003892V036/12/2007
p0003890V016/15/2007
p0003890V026/15/2007
p0003890V036/15/2007
p0001232V046/16/2007
p0001232V056/16/2007
p0001232V066/16/2007
p0001230V076/17/2007
p0001230V086/18/2007
p0001230V096/18/2007

We have 44 Safety training videos (15 minutes)

How can calculate the percentage of each employee in query ?

if emploee view 22 video it means that this employee
50% view the videos.


We have to calcuate
1. total number of video view by each employee, sum
2. each employee perentage of viewing.ie. percentage %
3. Group wise percentage, ?
we have three group A,B,and C, calcuate the each
group percentage in query ?


regards
Martin

View 4 Replies View Related

Calculating A Percentage

Mar 25, 2008

My site has members. Each member has a certain goal, an amount that they are hoping to raise. Here's my tables:

---------------------
Members
---------------------
ID | Goal
---------------------


---------------------
Donors
---------------------
Amount | MemberID
---------------------


I'm trying to get the percentage of money raised compared to their goal. Basically 100*(SUM(Amount)/Goal). Here's my stored procedure:

CREATE PROCEDURE sproc_GetGoalPercentage
(
@memberid int
)
AS
SELECT(SUM(D.Amount)/M.Goal)*100
FROMMembers AS M INNER JOIN Donors AS D
ON M.ID = D.MemberID
WHEREM.ID = @memberid
GROUP BY M.Goal
RETURN


All it does is return 0.

View 7 Replies View Related

Query For Percentage Of A SUM

Jul 23, 2005

I am trying to figure out the syntax for a query that will essentiallygive me the Percentage each of my areas contributes to the Whole. Iknow this can be achieved by multiple queries but I would like to keepit intact as one single query if possible.For Example I have the following data set--AREA MOUNE 1234SO 4312WE 12312MW 97123NE 1123SO 31WE 312MW 971The results I would like to see would look likeAREA MOU PERCENTMW 98094 .83536NE 2357 .02007WE 12624 .10751SO 4352 .03706The query I came up with is--SELECT DISTINCT Area, SUM(MOU) AS AREA_TOTAL, sum(MOU) /(SELECT SUM(MOU) AS TOTAL_MOUFROM [2004_NOVEMBER_COST])as[PERCENT]FROM [2004_NOVEMBER_COST]GROUP BY AreaAll seems to calculate with the exception of the Percent where all thepercentages are 0's.I think I need to take the first line AREA_TOTAL and now divide by theSUM(MOU) like this--SELECT DISTINCT Area, SUM(MOU) AS AREA_TOTAL, AREA_TOTAL /(SELECT SUM(MOU) AS TOTAL_MOUbut I get Invalid Column.I essence I think it is a simple query but I am hitting a wall. Anyadvice would help.Thanks,Ben

View 3 Replies View Related

Percentage Column AND Row

Jun 22, 2007

Hello,



I have a matrix that looks as follows:



Name Jan Feb Total

John 5 6 11

Mary 3 4 7

Total 8 10 18



I want to add a percent column to the RIGHT of the total, and also on the bottom row. I can't find any clear examples of how to do this. If I had a new column, it adds additional headers beneath my top row. Or, my columns appear to the LEFT of the data, not the right. Can some please post some simple instructions that will make my simple matrix look like this:



Name Jan Feb Total %

John 5 6 11 60%

Mary 3 4 7 40%

Total 8 10 18 100%

% 40% 60% 100% 100%



I am so stuck on this I can pull my hair out.



Thanks!



Michael



p.s. I really hope the next version of SSRS has a simple "Sub-total %" option that you can enable just like the sub-total column.

View 3 Replies View Related

Percentage Format

Feb 14, 2007

I am trying to display a figure as a Percentage.

The figure is 2.00000. I want it to show as 2.00%.

When i go into the formatting i select P but it displays the figure as 200.00%.

What formatting code should i use to get 2.00%?

View 7 Replies View Related

Percentage Not Being Calculated

Oct 5, 2007

What's incorrect with my sql so that the pct is not being calculated? I'm returning all zeros.
------------------------------------------------------------------------------------------------



SELECT

sa.schoolc sch#,

s.schname AS School,

Y = sum(CASE WHEN u.logindate IS NOT NULL THEN 1 END),

N = sum(CASE WHEN u.logindate IS NULL THEN 1 END),

pct = (sum(CASE WHEN u.logindate IS NOT NULL THEN 1 END)/

(sum(CASE WHEN u.logindate IS NOT NULL THEN 1 END)+sum(CASE WHEN u.logindate IS NULL THEN 1 END))) * 100


FROM

users AS u

INNER JOIN stugrp_active AS sa ON u.username = sa.suniq

INNER JOIN school AS s ON s.schoolc = sa.schoolc


WHERE

u.username like '3%'

AND sa.schoolc >= 300


GROUP BY

sa.schoolc,

s.schname


ORDER BY

sa.schoolc

View 12 Replies View Related

Total Value And Percentage

Sep 27, 2007



I'm supposed to generate a report like this.









Breakdown by Remaining Term
Balance
Balances as a %

0 thru 1 mos



1 thru 2 mos



2 thru 3 mos



3 thru 4 mos



4 thru 5 mos



5 thru 6 mos



6 thru 7 mos



7 thru 8 mos



8 thru 9 mos



9 thru 10 mos



10 thru 11 mos



11 thru 12 mos



Total




I'm wondering how to calculate the Balances as a %. Because I dont know how to calculate the Total for 12 months.

Basically Balances as a % = (Balance for 0 thru 1 mos / Balance for whole 12 mons)%

But the problem is calculating the total balance for 12 mons.

Can any one help me please?

View 6 Replies View Related

Pie Chart Having Percentage

Aug 22, 2007



Hello,
I am working on generating a Pie Chart in Reporting Services. I want to display percentage (%) in the pie chart slices, rather than having the actual values, since it does not fit properly into charts. A percentage would be better as a report.

Hope the question is clear. I would be grateful to anyone who answers this question.

thanks a lot.

View 5 Replies View Related

Group Percentage

Oct 26, 2007

I'm working with SQL RS 2000 and am putting together some pie charts. In my query, I am counting the total number of records grouped by a case statement so I get the total of one specific type and then the total of all other. What I am wanting to do is in addition to having the actual record count, I would like to also show the percentage of the whole. In the past, what I have done is written a separate query that does not do any grouping and then in my report, divide my individual total by my grand total and get my percentage that way.

I was just wondering if there is any way to get the percentage without having to write the additional query?

View 4 Replies View Related

Get Percentage From Two Columns

Feb 12, 2008

I am trying to get the a percentage from two columns, but I can not figure out how to do it. An example of my data is:

NAME MAX ACT
Red 1000 78
Blue 1000 247
Yellow 1000 472

My thoughts was to do something like:
SELECT NAME, MAX, ACT, ((ACT / MAX)*100) as PERCENTAGE
FROM TableName

When I do this the PERCENTAGE column just has 0s. Could someone tell me can this be done....and what am I missing.

FYI: Columns MAX and ACT are Int (4)

Thanks!!

View 5 Replies View Related

Getting Totals Help

Feb 22, 2004

I am using a web page to enter records into a table that tracks production on machine parts.

I get two recordsets and loop through them using vbscript to get the totals.

I use two because I first get all production data greater than the last date an event occurred. The second I get the totals for the day of because I have to back out shifts of production prior to the event, the day of the event (ie 3 shift per day, 3rd shift begins the day so a day looks like this 3, 1, 2. We do an event on shift 1. I have to back out shift 3 as it happened prior to 1. Once I have the two seperate totals I then write a record in the historical data table with the event, shift, production totals, etc.

My question is can I get the production totals from within SQL or is looping through the rs's in vb better?

the vb for the shift is similar to this
If last_event_shift = 1 then
DayProd = shift1prod + shift2prod
elseif last_event_shift = 2 then
DayProd = shift2prod
elseif last_event_shift = 3 then
DayProd = shift1prod + shift2prod + shift3prod
else
end if
TotProd = DayProd + GreaterProd


Here is the SQL for each rs
Data Greater than last date
Select Sum(Production)AS TotProd, dbo.Production.LineNum, EventType

From dbo.Production INNER JOIN dbo.EventDate ON dbo.Production.LineNum = dbo.EventDate.LineNum AND dbo.Production.EntryDate > dbo.EventDate.EntryDate

Where dbo.EventDate.LineNum = @Line
Group By dbo.Production.LineNum, dbo.EventDate.EventType

Data for the last date
Select Max(dbo.EventDate.ShiftRemoved) AS RemovedShift, dbo.EventDate.Set_Pos, Max(dbo.EventDate.CutOff)AS CutOff, dbo.EventDate.EntryDate, Sum(Production)AS TotProd, dbo.Production.LineNum, EventType, Shift

From dbo.Production INNER JOIN dbo.EventDate ON dbo.Production.LineNum = dbo.EventDate.LineNum AND dbo.Production.EntryDate = dbo.EventDate.EntryDate

Where dbo.EventDate.LineNum = @Line

Group By dbo.Production.LineNum, dbo.EventDate.EventType, Shift, dbo.EventDate.EntryDate, dbo.EventDate.Set_Pos

Thanks in advance,
Lee

View 2 Replies View Related

Totals

Mar 16, 2007

Hello All,



I have done a report that shows all the subtotals however, I want to show the grand total (the sum of each subtotal) in a row. I am using SQL server BI studio-2005. I know I can add a row but all the rows are detailed rows and subsequenlty reflect the subtotals for last record in the report. All I need to know what type of row do I need to add to show my totals.

Thanks,

Rashi

View 3 Replies View Related

Record Count Percentage

Jul 19, 2007

How do I write a query to give me the total records in databaseA.tableA divided by the total records in databaseB.tableA
This is what I have so far:DECLARE @today as datetime
DECLARE @past as datetime

/* set the dates */
set @today = getdate()
set @past = getdate() - 3 /* Go back 3 days */


/* create temp table for holding total cases*/
CREATE TABLE #CaseTotalCount
(
TotalCount int
)


/**/
CREATE TABLE #FlashCycleCount
(
FlashCount int
)

/**/

INSERT INTO #CaseTotalCount (TotalCount)
SELECT COUNT (DataBaseA.dbo.tblProcedureData.CaseID) as TotalCount
FROM DataBaseA.dbo.tblProcedureData
WHERE DataBaseA.dbo.tblProcedureData.Date < @today AND DataBaseA.dbo.tblProcedureData.Date > @past



/**/
INSERT INTO #FlashCycleCount (FlashCount)
SELECT COUNT (DataBaseB.dbo.tblFlashLog.FlashLogID) AS FlashCount
FROM DataBaseB.dbo.tblFlashLog
WHERE DataBaseB.dbo.tblFlashLog.LoadDate < @today AND DataBaseB.dbo.tblFlashLog.LoadDate > @past




/*function call*/
SELECT dbo.percentage(#FlashCycleCount.FlashCount, #PeriOpTotalCount.TotalCount)
FROM #FlashCycleCount
JOIN #PeriopTotalCount
ON #PeriOpTotalCount.TotalCount != 0 This works but when I try to bind this to a formview a get nothing. any ides? 

View 6 Replies View Related

Procedure Cache Percentage

Apr 26, 2000

Hi Everybody!

In the application I have, database interaction is mainly through stored procedures.

Currently the setting for procedure cache is 30%. Does anyone have experience with having had changed this and effect on performance?

Thanks!
- Manoj

View 1 Replies View Related

Find Percentage Of A Field

Jun 8, 2004

HOW can i get the percentage for each rank?
http://shahabedeen.europe.webmatrixhosting.net/pic/persentile04.gif

View 6 Replies View Related







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