Find 95th Percentile For BMI
Mar 3, 2015
I need to find patients(MRN) who are in the 95th percentile for BMI.
create table dbo.TEST
(
MRN varchar(10),
ResultValue varchar(10)
)
insert into dbo.TEST(MRN, BMI) values( '611193','25.63')
insert into dbo.TEST(MRN, BMI) values( '128845','16.93')
[Code] .....
View 9 Replies
ADVERTISEMENT
Sep 15, 2006
I am stumped on a set-based approach for this one.
A cursor approach is straightforward enough, but i want to avoid that.
Here's my table:
create table StudentScores
(
id int primary key identity(1,1),
student_id int not null,
score int not null
)
with some sample data:
insert into StudentScores (student_id, score)
select 1, 10 union all
select 1, 29 union all
select 1, 50 union all
select 1, 53 union all
select 1, 45 union all
select 1, 10 union all
select 1, 29 union all
select 1, 50 union all
select 1, 53 union all
select 1, 45 union all
select 1, 88 union all
select 2, 23 union all
select 2, 54 union all
select 2, 55 union all
select 2, 34 union all
select 2, 56 union all
select 2, 78 union all
select 2, 23 union all
select 2, 54 union all
select 2, 55 union all
select 2, 34 union all
select 2, 56 union all
select 2, 78 union all
select 2, 23 union all
select 2, 54 union all
select 2, 55 union all
select 2, 34 union all
select 2, 56 union all
select 2, 78 union all
select 2, 98
What I want is, for each student, what is their 90th percentile score?
For a given single student, one possibility would be:
declare @studentid int
set @studentid = 2
select top 1 @studentid as student_id, a.score as [90th percentile score]
from
(
select top 90 percent score from StudentScores
where student_id = @studentid order by score asc
) as a
order by a.score desc
But I want this for all students, and not use a cursor.
Any ideas?
Thanks!
View 6 Replies
View Related
Dec 14, 2007
How to create Percentile with MDX??
i got this function but i'm not success to follow up.
Percentile ( set, numeric_value_expr, percentile )
(set -> The set from which to get a tuple value.
numeric_value_expr -> A numeric value or an expression that returns a numeric value.
percentile -> A percentile. Must be between 0 and 100. )
Thank you
View 5 Replies
View Related
Apr 28, 2006
Hi, l would like to calculate 80% and 95% percentile of a column from my table in SQL server 2005. Does SQL server 2005 provides such built-in function, if not, how should l do? Any suggestion? (Suggest to MS : Please include percentile as a built-in function on the next services pack). Thanks and happy labor day!
View 6 Replies
View Related
Jan 13, 2008
SCORE ID PERCENTILE
0.500 1 ?
0.500 2 ?
0.450 3 ?
0.290 4 ?
0.540 5 ?
0.460 6 ?
I have SCORE and ID how can I calculate the percentile?
SCORE ID PERCENTILE
0.500 1 ?
0.500 2 ?
0.450 3 ?
0.290 4 0
0.540 5 100
0.460 6 ?
This table has a large number of rows
View 1 Replies
View Related
Oct 11, 2005
Hi All,
I have around 1000 employee records containing employee number and their salary. How do i calculate percentile on these records?
For example
How to calculate 25th Percentile on Salary of these 1000 records?
Hope I am clear with my question.
Thanks in advance.
Regards,
qA
View 7 Replies
View Related
Jun 20, 2007
Hello All,
Does anyone know how to do an expression that calculate percentrank and percentiles? I have a table with a list of transactions and their response time. I need to find the 75th, 90th, 95th, and 98th percentile as well as the percentrank of <=5 seconds, 10 seconds, 30 seconds and 60 seconds.
Any help is appreciated!
View 8 Replies
View Related
Dec 29, 2014
I am using sql server 2008 to calculate the percentile value for each column.
--Script
CREATE TABLE #Table (Score Varchar(4),Percentile int)
INSERT INTO #Table (Score)
VALUES
('80'),('55'),('125'),('99'),('75'),('130'),('37'),('73'),('151')
select * from #Table
I would like the result to be shown in 25,50,75,100 percentile values . Here is the example
Score | percentile
80 | 75
37 | 25
151 | 100
75 | 50
View 9 Replies
View Related
Mar 22, 2007
I'm trying to create a calculated field that gives me the avg 75 percentile.
Right now I get this value by doing the following:
Create data set:
Select top 75 percent <field>
from <table>
Then I create the following calculated field
Avg(Fields!<field>.value,"<data_set_name>")
But I wanted to be able to create a calculated field that gives me the avg 75 percentile without creating a separate data set to get the top 75 percent Value.
Is it possible?
Thanks!
View 9 Replies
View Related
Jul 26, 2015
I am writing some scripts to calculate mean (avg) stdevs count and percentile_cont for some data..I am partitioning over multiple columns e.g. partition by year,month, day order by value..I performing unnecessary overhead as I throw away all but the last (or max) value in each window. (I use cte then select max from cte).That is I only care about the avg of the window in its entirety not specific subwindows.
View 5 Replies
View Related
Sep 15, 2015
I have process and people want to know percentile rank (on scale of 100), I'm bit lost as I have cases when I have let say 5 observations, so if use code below I can not got above number of observations:
Is there any way to get that numbers like RankWanted ??
; WITH cte AS (
SELECT 100 Cust_ID , 0.338129 Perc, 20 RankWanted union
SELECT 300 Cust_ID , 0.487179 Perc, 40 RankWanted union
SELECT 300 Cust_ID, 0.500000 Perc, 60 RankWanted union
SELECT 400 Cust_ID, 0.541666 Perc, 80 RankWanted union
SELECT 500 Cust_ID, 0.548780 Perc, 100 RankWanted )
SELECT Cust_ID, Perc,
[code].....
View 2 Replies
View Related
Sep 16, 2015
Any good way to add a percentile calculation to a table in sql server 2008 r2?
I've got 4 fields and I'd like to add a 5th labeling the records according to the percentile they fall in for one of the fields.
View 4 Replies
View Related
Jul 26, 2005
I tried all the INFORMATION_SCHEMA on SQL 2000 andI see that the system tables hold pretty much everything I aminterested in: Objects names (columns, functions, stored procedures, ...)stored procedure statements in syscomments table.My questions are:If you script your whole database everything you end up havingin the text sql scripts, are those also located in the system tables?That means i could simply read those system tables to get any informationI would normally look in the sql script files?Can i quickly generate a SQL statement of all the indexes on my database?I read many places that Microsoftsays not to modify anything in those tables and not query them since theirstructure might change in future SQL versions.Is it safe to use and rely the system tables?I basically want to do at least fetching of information i want from thesystem tables rather than the SQL script files.I also want to know if it's pretty safe for me to make changes in thesetables.Can i rename an object name for example an Index name, a Stored Procedurename?Can i add a new column in the syscolumns table for a user table?Thank you
View 4 Replies
View Related
Jun 12, 2008
I have 3 database say
db1
db2
db3
I need to setup a script to read all the table names in the database above and then query the database to find the list of Stored Procedure using each table.(SQL Server)
View 5 Replies
View Related
Mar 6, 2001
Hello!
Please help me to find web page where guys who passed MS exams share their experience. I remember it should be like BenyenVine or very close...
Thank you,
Elena
View 2 Replies
View Related
Jun 12, 2007
Everytime I search for this text, it seems to pick up stuff beginning with 5, not dash 5. Does something need to be escaped and how would this be done?
View 8 Replies
View Related
Mar 2, 2006
Sometimes the simplest things are the most difficult... I'm creating a
UDF as below, then executing it but all I get is that the object does not exist. I must be missing something very basic here...
CREATE function dbo.GetColumnLength(@vcTableName varchar(50), @vcColumnName varchar(50)) returns smallint
as
begin
declare @intLength as smallint
select @intLength=sysC.prec from syscolumns sysC, sysobjects sysO
where sysC.Id = sysO.Id AND sysO.xtype ='U' And
sysO.Name = @vcTableName AND
sysC.Name = @vcColumnName
return @intLength
End
GO
select top 2 * from player, dbo.GetColumnLength('playerdetails','email')
View 7 Replies
View Related
Oct 23, 2007
Some pre-written scripts that contain things such as automobile make or other generic common data like that?
I'm trying to avoid populating my db by hand. Any insight would be appreciated.
cheers
View 3 Replies
View Related
Jul 20, 2005
Can someone help on this:I am just learning, and I'm connecting to the the northwindcs.mdf tables /open file is northwindcs.adp.This is the sample installed using msde, which is supposed to be mini sqlserver to learn.Please don't refer me elsewhere, here is what I'm trying to learn:If I want to hit a command button and do the following:1. Find a customerid2. if found, edit the record, if not found, add a new record.How would the below code need to look for this, I'm not even sure theconnection string is correct.I'm getting following error:run-time error 3219operation not allowed in this context.I get the y messagebox, but rst!ContactTitle = "The Owner" doesn't work.When I hit the debug, rst.close is highlighted.Also, how do you handle a no find situation here, I noticed a nomatchdoesn't work.I am real good at programming, but new to the server thing.And finally, is there a way to hit this command button, and do all from astored procedure instead of code? But in background, no user inteventiononce button is hit. Which is better, this code approach or a possiblestored procedure.Please help, if I get this down, I think I'll have the rest wipped. Theconnect string is one big thing confusing me along with handling record oncefound / not found. I'm used of DAO. If some one is willing to help, I canemail detailed real code from a database I'm really working on. I need tolearn this first to convert code.HERE IS SAMPLE CODEPrivate Sub Command16_Click()Dim cnn As New ADODB.ConnectionDim rst As New ADODB.RecordsetDim mark As VariantDim count As Integercount = 0cnn.Open "DSN=NorthwindCS; Provider=SQLOLEDB;Data Source=OEMCOMPUTER;InitialCatalog=NorthwindCS; uid=sa; pwd=;"rst.Open "SELECT * FROM Customers", cnn, _adOpenDynamic, adLockOptimistic, adCmdText'rst.Open "SELECT CustomerID FROM Customers", cnn, _' adOpenDynamic, adLockReadOnly, adCmdText' The default parameters are sufficient to search forward' through a Recordset.rst.Find "CustomerID = 'CHOPS'"If rst!CustomerID = "CHOPS" ThenMsgBox "y"rst!ContactTitle = "The Owner"ElseMsgBox "n"End If' Skip the current record to avoid finding the same row repeatedly.' The bookmark is redundant because Find searches from the current' position.'Do While rst.EOF <> True 'Continue if last find succeeded.' Debug.Print "Title ID: "; rst!CustomerIDcount = count + 1 'Count the last title found.'mark = rst.Bookmark 'Note current position.'rst.Find "CustomerID = 'CHOPS'", 1, adSearchForward, mark'Exit Do'Looprst.Closecnn.CloseDebug.Print "The number of business titles is " & countEnd Sub
View 8 Replies
View Related
Sep 13, 2006
To ensure I don't leave orphans floating around in tables when records get deleted (values from one record might link to values in another) how do I find and possibly replace values in tables?For example, if I have a unit of measure table and want to delete the value "inches", how do I look in other tables to find this value and give the user the option to cancel or clear it out. If I don't it will cause controls bound to that value like the dropdownlist to throw an error.
View 1 Replies
View Related
Jun 22, 2007
I have a visual studio 2005 app that has to match strings to something in a database.
It works wonderfully until a string shows up with an & in it (so "this & that")
The app wont find anything even though it should, the same query that is made in VS works just fine in enterprise manager
I tried a replace on the & with the chr(), hex, and html reference for & and none of those work.
We tried using different methods in VS to do the sql statement and commands.
The statement surrounds the string with single quotes.
If we take the & out, everything works fine.
Turned off request valadation just in case.
Any ideas?????
View 8 Replies
View Related
Feb 26, 2008
I am a novice....
Where would I start, if I wanted to search my SQL database for a record and have SQL return a true/false. I want this to be done with ASP.net.
View 1 Replies
View Related
Apr 26, 2008
Hello.I have a select that returns some SubCategories.SELECT SubCategoryID from SubCategories SCATINNER JOIN Categories CAT on CAT.CategoryId = SCAT.ParenCategoryIdWHERE SCAT.ParentCategoryId = X Now i will to retrieve all rows from a Table called Items Where Items.SubCategoryId will be any of the previous SubCategoryId's returned by the above SELECT query.What code i need to write toI think .. Select * from Items AS IT WHERE IT.Subcategory = ???I don't know, anyone can help meThanks
View 4 Replies
View Related
Apr 30, 2004
Does anybody know how to search through all stored procedures (in SQL Server 2000) and find and replace text without having to open each one individually in Query Analyzer and doing so one at a time?
That would be so time consuming. I want to be able to change my table names, but I have so many stored procedures allready using the old names. To go and find each name and replacing them is a task I don't want to even try and do.
Thank you to whomever can help.
Alec
View 1 Replies
View Related
Sep 1, 2004
My ISP runs MS SQL server for me and does not have experience managing this type of database. For example, the database occassionally crashes and looses data. Our site is not live yet, but once we go live, this is unacceptable.
I need somebody to consult on the database configuration, tuning, security and maintenance plan. How would I find a person with the correct qualifications?
View 1 Replies
View Related
Feb 13, 2006
I have the following in my web.config<appSettings> <add key="strConn" value="server=10.100.1.2;uid=sa;pwd=;database=MyDB/></appSettings>and I am getting the following error message --"SQL Server cannot be found or access denied"if I replace the server IP address with server name, it works fine. Am I missing something here? Help!ThanksBugme
View 1 Replies
View Related
Dec 17, 2001
Where to look for the web assitant created jobs on the server?I created a web page using the web assistant which is suppossed to get updated each time a value changes in a particular table,but I can't find the task which I created ,where do i look for that?I didn't use this wizard previously.thanks for any help!
Sheila.
View 1 Replies
View Related
Jun 5, 2001
Hi, All
I have a problem with one table.
This table is corrupted so I drop the table and recreate the table..(Of course I export data) After that I try to put the primary key to new table but it won't allow me to do it. Error message says " There are duplicated key existed" Therefore I open up the EM and take a look at that table. There is key in that table but not Primary key..(also from the query analyzer using sp_help)
My question to U is how can I find this duplicated key and delete that info? I think somewhere in the system table contains this info but I don't know where:-(((
Thanks in advance..
Jay
View 1 Replies
View Related
Feb 1, 2001
I'm doing a query using SQL Server. How can I get the max and min date from a database? I can't find any function related to it. Can you help me please ....
Thanks in advance
Andy
View 1 Replies
View Related
Aug 30, 2000
Hello!
I have 80 tables in the database and I need to find in which table particular column exist. How can I do it shortly, without naming every table in my query?
Thank you.
View 1 Replies
View Related
Dec 11, 2000
Can any one tell me what could be the probable reason for the following error.
'could not find the stored procedure sp_xxxx
/shopa/fgh/dbconn.asp'
even though the stored procedure is verymuch there on the server. This error pops up frequently,not allways.Any help on what I should do??
Thanks!
View 4 Replies
View Related
Dec 4, 2002
Hi,
how can i find if a field in one table has a relationship to a field in another table and how can i get additional inforation about this relation?
thanks
View 7 Replies
View Related
Jun 9, 2004
Hi,
I have sciprt that assign object
permissions to all databases.
I want to exclude all read only and dbo use only databases
Thank you
Alex
View 6 Replies
View Related