Mean, Minimum, Maximum, Standard Deviation Of Time
May 7, 2007
I have a report that calculates mean, min, max, stddev of somer exercises for a class (pushups, situps, trunk lifts, etc). I also have to calculate those for the 1-mile run time (ex: data -- 7:56, 6:35, 9:45 ( in minuteseconds). Obviously the standard Avg(), Min(), Max(), StdDev() functions won't work for time. So I put in some custom code to convert the time to seconds so I can use the standard functions on the seconds and also code to convert that answer back to minuteseconds. Max() works, but for example when I try to calculate the min(), it includes nulls from the dataset as zeros (not every student has to do the mile run). So the min is always 0. How can I exclude nulls from being calculated. The min() function excludes nulls so it returns the correct min() on integer data. What else can I do?
View 3 Replies
ADVERTISEMENT
Jul 27, 2015
I have below table structure
DECLARE @table Customer (Date DATE, CustomerID VARCHAR(5))
INSERT INTO @Customer (Date, CustomerID) VALUES
('2/6/2015','ADXPA'),
('2/6/2015','AKXLV'),
('2/7/2015','CPDYA'),
('2/7/2015','ZXDQW'),
('2/8/2015','LK1MP'),
etc, till 3836 Records for '2/8/2015' and 4869 Records for '2/8/2015' etc...
Now, I want to take the records which are meeting the standard deviation value of count of CustomerIDs in the group.
Date Count of Customers Avg. Count STD DEV
2/6/2015 2 3944.07 1849.61
2/7/2015 2 3944.07 1849.61
2/8/2015 3836 3944.07 1849.61
2/9/2015 4869 3944.07 1849.61
[Code] ....
Here I want to filter out +/- STDDEV of Average - So I need to filter out rows with dates 2/6/2015, 2/7/2015 and 2/16/2015 since these values not in the range of +/- STDDEV of Average.
Here CustomerID is Varchar type, So we need to convert them to Count first partitioning the Date Column and take the average and STDDEV of all without any partition...
View 17 Replies
View Related
Dec 6, 2004
Hallo Cracks,
what I try is a little bit heavy, maybe, but I only miss the minimum/maximum fuction - or I didn´t found it; not here in the Forum and also not in the onlinehelp of the SQL Server.
What I try to do:
I have 2 columns in my table; a start- and an end-date. For this period of time between end and start i have to calculate the days for the years. Here my thoughts (for the current year):
Is the startdate <= 31.12.2004 and the enddate >= 1.1.2004 i have to calculate die datediff between max(1.1.2004/startdate) and min(31.12.2004/enddate)
like this sqlstatement:
SELECT CASE WHEN dbo.Phases.phasenstart <= CAST(CAST(YEAR(GETDATE()) AS
varchar) + '-31-12' AS smalldatetime) AND dbo.Phases.phasenabschlussist >=
CAST(CAST(YEAR(GETDATE()) AS varchar) + '-01-01' AS smalldatetime)
THEN 365 ELSE 0 END AS Expr2,
FROM dbo.Phases
WHERE (phasenstart IS NOT NULL) AND (phasenabschlussist IS NOT NULL)
instead of 365 there must be the above calculation. Is start=3.1.2003 and end=30.1.2004 I expect as result only the 30 days in 2004.
thanks in advance and kind regards :-)
Cappu
View 2 Replies
View Related
Sep 16, 2012
I am trying to get the minimum and maximum values from a field in SQL Server 2008 Express, but I cannot even get started because I keep getting this error that I cannot figure out.
View 6 Replies
View Related
May 23, 2014
Table definition:
Create table code (
id identity(1,1)
code
parentcode
internalreference)
There are other columns but I have omitted them for clarity.
The clustered index is on the ID.
There are indexes on the code, parentcode and internalreference columns.
The problem is the table stores a parentcode with an internalreference and around 2000 codes which are children of the parentcode. I realise the table is very badly designed, but the company love orms!!
Example:
ID| Code| ParentCode| InternalReference|
1 | M111| NULL | 1|
2 | AAA | M111 | 2|
3 | .... | .... | ....|
4 | AAB | M111 | 2000|
5 | M222 | NULL | 2001|
6 | ZZZ | M222 | 2002|
7 | .... | .... | .... |
8 | ZZA | M222 | 4000|
The table currently holds around 300 millions rows.
The application does the following two queries to find the first internalreference of a code and the last internal refernce of a code:
--Find first internalrefernce
SELECT TOP 1 ID, InternalReference
FROM code
WHERE ParentCode = 'M222'
Order By InternalReference
-- Find last ineternalreference
SELECT TOP 1 ID, InternalReference
FROM code
WHERE ParentCode = 'M222'
Order By InternalReference DESC
These queries are running for a very long time, only because of the sort. If I run the query without the sort, then they return the results instantly, but obviously this doesn't find the first and last internalreference for a parentCode.
I realize the best way to fix this is to redesign the table, but I cannot do that at this time.
Is there a better way to do this so that two queries which individually run very slowly, can be combined into one that is more efficient?
View 7 Replies
View Related
Jul 23, 2005
I have a problem (who not?) with a function which i'm using in a view.This function is a function which calculates a integer value of adate. For example: '12/31/2004 00:00:00" becomes 20041231. This isvery handy in a datawarehouse and performes superfast. But here is myproblem.My calendar table is limited by a couple of years. What happens isthat sometimes a value is loaded which is not in the range of theCalendardate. What we want to do is when a date is loaded is that thisfunction insert a minimum date when date < minimum date and a maximumdate when date > maximum date.Yes i know you're thinking : This is datamanipulation and yes this istrue. But now we loose information in our cubes and reports by innerjoining. So if we can use a minimum and a maximum than a user wouldsay: "This is strange, a lot of values on 1980/1/1!" instead of "Ithink that i have not all the data!"GreetzHennie
View 2 Replies
View Related
Jul 23, 2005
Because of an error in google or underlying site i can reply on my ownissue. Therefore i copied the former entered message in this message.-------------------------------------REPY----------------------------------Hi Maybe i wasn't clear. I want to dynamically check whether what thelowest date and the highest date is in the calendar table. Thepresented solutions has fixed dates and i don't want that.If i could store a global variable in SQL server (dynamic properties?)then it would be great. Fill this once and call it multiple times inmy intensively used function. Is this possible?GreetzHennie----------------------------Previously enteredissue-----------------------I have a problem (who not?) with a function which i'm using in a view.This function is a function which calculates a integer value of adate. For example: '12/31/2004 00:00:00" becomes 20041231. This isvery handy in a datawarehouse and performes superfast. But here is myproblem.My calendar table is limited by a couple of years. What happens isthat sometimes a value is loaded which is not in the range of theCalendardate. What we want to do is when a date is loaded is that thisfunction insert a minimum date when date < minimum date and a maximumdate when date > maximum date.Yes i know you're thinking : This is datamanipulation and yes this istrue. But now we loose information in our cubes and reports by innerjoining. So if we can use a minimum and a maximum than a user wouldsay: "This is strange, a lot of values on 1980/1/1!" instead of "Ithink that i have not all the data!"GreetzHenniePlaats een reactie op dit berichtBericht 2 van deze discussieVan:John Bell (jbellnewsposts@hotmail.com)Onderwerp:Re: Intensively used function in view needs a minimum andmaximum from a tableView this article onlyDiscussies:comp.databases.ms-sqlserverDatum:2004-12-30 03:56:25 PSTHiIf you LEFT or RIGHT JOIN to the calendar table you will get a NULLvaluefor the column, you can then is CASE to determine the valueCREATE FUNCTION ConvertDate (@datevalue datetime)RETURNS INTASBEGINDECLARE @dateint INTSELECT @dateint = CAST( CASE WHEN A.Date < '20030101' THEN '19800101'WHEN A.Date > '20051231' THEN '99991231'ELSE CONVERT(CHAR(4),C.[Year]) + RIGHT('0'+CONVERT(VARCHAR(2),C.[Month]),2) + RIGHT('0'+CONVERT(VARCHAR(2),C.[Day]),2)END AS INT )FROM ( SELECT @datevalue AS [Date] ) ALEFT JOIN CALENDAR C ON C.[Date] = A.[Date]RETURN @dateintENDGOJohn"Hennie de Nooijer" <hdenooijer@hotmail.com> wrote in messagenews:191115aa.0412300238.7dee0f85@posting.google.c om...[color=blue]>I have a problem (who not?) with a function which i'm using in a[/color]view.[color=blue]> This function is a function which calculates a integer value of a> date. For example: '12/31/2004 00:00:00" becomes 20041231. This is> very handy in a datawarehouse and performes superfast. But here is my> problem.>> My calendar table is limited by a couple of years. What happens is> that sometimes a value is loaded which is not in the range of the> Calendardate. What we want to do is when a date is loaded is that this> function insert a minimum date when date < minimum date and a maximum> date when date > maximum date.>> Yes i know you're thinking : This is datamanipulation and yes this is> true. But now we loose information in our cubes and reports by inner> joining. So if we can use a minimum and a maximum than a user would> say: "This is strange, a lot of values on 1980/1/1!" instead of "I> think that i have not all the data!">> Greetz>> Hennie[/color]Plaats een reactie op dit berichtBericht 3 van deze discussieVan:Hugo Kornelis (hugo@pe_NO_rFact.in_SPAM_fo)Onderwerp:Re: Intensively used function in view needs a minimum andmaximum from a tableView this article onlyDiscussies:comp.databases.ms-sqlserverDatum:2004-12-30 15:32:06 PSTOn 30 Dec 2004 02:38:51 -0800, Hennie de Nooijer wrote:[color=blue]>I have a problem (who not?) with a function which i'm using in a[/color]view.[color=blue]>This function is a function which calculates a integer value of a>date. For example: '12/31/2004 00:00:00" becomes 20041231. This is>very handy in a datawarehouse and performes superfast. But here is my>problem.[/color](snip)Hi Hennie,Is this conversion all that your function does? If so, you might wanttotry the following alternative (using CURRENT_TIMESTAMP as example;replaceit with your date column / parameter):SELECT CAST(CONVERT(varchar, CURRENT_TIMESTAMP, 112) AS int)You could put this in the UDF (probably at least as fast as yourcurrentCalenmdar-table based function), or use it inline as a replacement tothefunction call (probably even faster).It should work for all dates from Jan 1st 1753 through Dec 31st 9999.Best, Hugo--(Remove _NO_ and _SPAM_ to get my e-mail address)
View 2 Replies
View Related
Sep 3, 2013
I receive the following result set from TableA (In Time)
7/9/2013 9:27:00.000 AM
7/9/2013 10:24:00.000 AM
7/9/2013 11:25:00.000 AM
7/9/2013 1:23:00.000 PM
7/10/2013 7:27:00.000 AM
Then we receive the following result from TableB (Out Time)
7/9/2013 9:30:00.000 AM
7/9/2013 10:29:00.000 AM
7/9/2013 1:37:00.000 PM
[NULL]
[NULL]
We may not always get Out Times in TableB so I want to merge these into one table to have the In Time and Out Time in separate columns in that one table. In this example with the red type those should be In Time and Out Time for mapped unique identifiers from each table and yet the purple color coded example would have an In Time of 11:25 AM and the Out Time would remain as NULL.
I am using this block of code but is not working the way I want it to because the 11:25am In Time is getting mapped to the 1:37pm Out Time.
and out_time = (select min (out_time)
FROM tableB WHERE
tableB.record# = tableA.record#
and tableB.loc_id = tableA.loc_id
GROUP BY tableB.record#, tableB.loc_id )
It seems I need to focus on the minimum datediff for each record line but can't figure that part out.
View 2 Replies
View Related
Feb 20, 2002
Hello,
I have been trying to find out what the maximum memory we can have on SQL7 standard edition server. Have not been able to find it anywhere...
Anuy ideas would be greately appreciated.
TIA
B.
View 1 Replies
View Related
Apr 28, 2015
I need to provide a minimum value over a 12 hour time range of data. I'm struggling with performance issues due to the amount of data. Currently I log about 100 devices reporting once per minute into a table. Also about once per minute I need to pull the minimum value reported for each device in the last 12 hours. Currently I'm maintaining a separate table with entries for just the last 12 hours and just performing a Select Min(Temp) Where DeviceID=x, but it already holds about 700,000 records at any given time. The number of devices will increase substantially and this will no longer be viable.
Sample Table
ID DeviceID Temp InsertDate
1 10 55 04-28-2015 8:00 AM
2 65 74 04-28-2015 8:00 AM
3 44 23 04-28-2015 8:00 AM
4 10 87 04-28-2015 8:01 AM
5 65 65 04-28-2015 8:01 AM
View 3 Replies
View Related
Sep 8, 2015
I have a table with following data
(Id, date ,time)
11 2015/8/1
12:20:00
11
2015/8/1 12:21:00
11 2015/8/1
18:05:20
12 2015/8/1
11:20:00
12 2015/8/1
11:21:00
12 2015/8/1
18:10:20
I need the table with following record only
(Id, date ,time)
11 2015/8/1
12:20:00
11 2015/8/1
18:05:20
12 2015/8/1
11:20:00
12 2015/8/1
18:10:20
View 7 Replies
View Related
Dec 4, 2007
I have two fields which im trying to convert to standard time. IE (09:05 PM) or (12:00 AM).
They are in Military format right now. so i have 15:45 and 21:30 etc etc.
They are both Chars. And its just times and no dates. Can anyone help??
View 7 Replies
View Related
Feb 20, 2013
I have to build a database model, create tables and use triggers or/and procedures on it. It's about a library. Books are borrowed by students. They can make a reservation of a book.
I built the database model so far. My problem is how to represent following tasks:
- Students can borrow a maximum of 5 books at the same time.
- bookings/book reservations should be later processed in the order they occurred. That is, who first flagged the book also gets the book/books first
I have following entities:
- Book
- Book exemplar
- Borrowed by (a table between the entities Book exemplar and Student)
- Reserved for (a table between the entities Book exemplar and Student)
- Student
How would you represent the tasks I mentioned above in terms of triggers or procedures?...
View 5 Replies
View Related
Jul 15, 2014
I need to write down a sql query wherein in one particular day(user will enter manually), i need to find out a 15 minutes slot wherein purchase order's created or updated are the highest.
i.e. out of 96 slots(15 minute slot each)-I need to find the slot which has maximum number of Purchase orders created or updated.
View 7 Replies
View Related
Aug 7, 2001
My question here is whether or not MS SQL is processing joins according to the ANSI SQL standard. The situation is this, a friend of mine has the following query (The definition for the tables and the data in them are at the end of the message):
SELECT t.*, v.*
FROM Table3 T LEFT OUTER JOIN
TableView V ON T.tx = V.tx
WHERE V.tx IS NULL and V.part IN (1,2)
My friend is implying that the OUTER join takes precedence over the WHERE clause and should return ALL rows from table3 that don't exist in the view. The view, as you will see below, is a partitioned view. My contention is that the proper join processing is to join the tables first and then apply the WHERE clause to that result set (regardless of the join type). In my friend's case, he expects this query to return four rows. My expectation is that it will return zero rows, because in the result set after the join is performed there are no rows that have a NULL in the v.tx column AND 1 or 2 in the v.part column. The actual ouput agrees with my premise and my friend is sure that this is not proper ANSI SQL join processing. Is this proper ANSI join processing or is MS SQL deviating from the standard?
/************************************************** **********************/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Table1]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[Table1]
GO
CREATE TABLE [dbo].[Table1] (
[Part] [tinyint] NOT NULL ,
[id] [int] NOT NULL ,
[tx] [INT] NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[Table1] WITH CHECK ADD
CONSTRAINT [PK_Table1] PRIMARY KEY CLUSTERED
(
[Part],
[id]
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[Table1] WITH CHECK ADD
CONSTRAINT [CK_Table1] CHECK ([Part] = 1)
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Table2]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[Table2]
GO
CREATE TABLE [dbo].[Table2] (
[Part] [tinyint] NOT NULL ,
[id] [int] NOT NULL ,
[tx] [INT] NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[Table2] WITH CHECK ADD
CONSTRAINT [PK_Table2] PRIMARY KEY CLUSTERED
(
[Part],
[id]
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[Table2] WITH CHECK ADD
CONSTRAINT [CK_Table2] CHECK ([Part] = 2)
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Table3]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[Table3]
GO
CREATE TABLE [dbo].[Table3] (
[tx] [int] NOT NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[Table3] WITH CHECK ADD
CONSTRAINT [PK_Table3] PRIMARY KEY CLUSTERED
(
[tx]
) ON [PRIMARY]
GO
--DROP VIEW TableView
CREATE VIEW TableView AS
SELECT * FROM Table1
UNION ALL
SELECT * FROM Table2
GO
INSERT TableView (Part,Id,Tx) VALUES (1,1,1)
INSERT TableView (Part,Id,Tx) VALUES (1,2,2)
INSERT TableView (Part,Id,Tx) VALUES (1,3,NULL)
INSERT TableView (Part,Id,Tx) VALUES (2,4,4)
INSERT TableView (Part,Id,Tx) VALUES (2,5,5)
INSERT TableView (Part,Id,Tx) VALUES (2,6,NULL)
INSERT Table3 (tx) VALUES (1)
INSERT Table3 (tx) VALUES (2)
INSERT Table3 (tx) VALUES (3)
INSERT Table3 (tx) VALUES (4)
INSERT Table3 (tx) VALUES (5)
INSERT Table3 (tx) VALUES (6)
INSERT Table3 (tx) VALUES (7)
INSERT Table3 (tx) VALUES (8)
GO
View 1 Replies
View Related
Dec 14, 2007
Is there a function in SQL Server 2005 that can add GMT deviation hours to the existing date. I have a data field with the GMT_Deviation_Hours listed in numeric format e.g. -1, 12 etc. I have another date field to whom i wish to deviate the datetime according to the GMT_Deviation hours.
Thanks
View 2 Replies
View Related
Jun 21, 2007
Hi All,
I want to create following matrix report on SSRS.
Yearmonth
Jan-07
Feb-07
Mar-07
Apr-07
May-07
Sales
Deviation
Sales
Deviation
Sales
Deviation
Sales
Deviation
Sales
Deviation
Product
X1
100
0
110
10
130
20
100
-30
90
-10
Here the Problem is i want calculate Deviation:
Deviation for Feb 07= Sales in Feb - Sales In Jan
Deviation For Mar 07 = Sales in Mar - Sales in Feb.
I don't know how to apply formula in Matrix:
Is anybody hele me???
Thank You.
Balwant Patel.
View 6 Replies
View Related
Apr 9, 2008
Hello,
I have a database field that is just an appointment time but it is stored as a char and it appears to be in military time as well.
For reporting purposes I am creating a query that will use the appointment time and I need it to display in standard time format. I am doing this report in crystal and I tried to use crystal tools but it crystal recognizes it as a string so it won't let me set the time format. Is their a cast or convert or some type of sql function I can use to select the appointment time in standard time format? I have been searching online and just haven't found anything yet.
Thanks in advance!
Sherri
View 9 Replies
View Related
Oct 13, 2005
Dear group,is it possible in SQL-Server to see when a stored procedure wasexecuted ?I would say it is only possible with some traces but not with thestandard settings.For a short answer on that matter i'd be thankful.RegardsUli
View 4 Replies
View Related
Sep 12, 2015
I have some code I build 2 weeks ago which I’ve been running daily but it’s suddenly stopped working with the following error.
“The table "tbl_Intraday_Tmp" has been created, but its maximum row size exceeds the allowed maximum of 8060 bytes. INSERT or UPDATE to this table will fail if the resulting row exceeds the size limit” When I google this there seems to be a related to tables with vast numbers of columns.
My table tbl_Intraday_tmp is relatively small. It has 7 columns. 1 of varchar(5), 3 of decimal(9,3) and 2 of decimal(18,0). The bit I’m puzzled with is it was working and stopped.
I don’t recall changing anything but I wouldn’t rule that out. I ‘ve inspected the source files and I don’t believe they have changed either.
DECLARE
@FileName varchar(50),
@Path varchar(50),
@SqlCmd varchar(1000)
= '',
@ASXCode varchar(5),
@Offset decimal(18,0),
[code]....
View 5 Replies
View Related
Apr 20, 2012
I am using MS SQL server 2008, and i have a table with 350 columns and when i m trying to create one more column its giving error with below message -
Warning: The table XXX has been created, but its maximum row size exceeds the allowed maximum of 8060 bytes.
INSERT or UPDATE to this table will fail if the resulting row exceeds the size limit.
how can i resolve this?
View 14 Replies
View Related
Oct 10, 2005
SQL Server 2000 8.00.760 (SP3)I've been working on a test system and the following UDF worked fine.It runs in the "current" database, and references another database onthe same server called 127-SuperQuote.CREATE FUNCTION fnGetFormattedAddress(@WorkID int)RETURNS varchar(130)ASBEGINDECLARE@Address1 As varchar(50)@ReturnAddress As varchar(130)SELECT@Address1 = [127-SuperQuote].dbo.tblCompany.Address1FROM[Work] INNER JOIN[127-SuperQuote].dbo.tblCompany ON [Work].ClientID =[127-SuperQuote].dbo.tblCompany.CompanyIDWHERE[Work].WorkID = @WorkIDIF @Address1 IS NOT NULLSET @ReturnAddress = @ReturnAddress + @Address1 + CHAR(13)+ CHAR(10)RETURN @ReturnAddressENDSo now the system has gone live and it turns out that the live"SuperQuote" database is on a different server.I've linked the server and changed the function as below, but I get anerror both in QA and when checking Syntax in the UDF builder:The number name 'Zen.SuperQuote.dbo.tblCompany' contains more than themaximum number of prefixes. The maximum is 3.CREATE FUNCTION fnGetFormattedAddress(@WorkID int)RETURNS varchar(130)ASBEGINDECLARE@Address1 As varchar(50)@ReturnAddress As varchar(130)SELECT@Address1 = Zen.SuperQuote.dbo.tblCompany.Address1FROM[Work] INNER JOINZen.SuperQuote.dbo.tblCompany ON [Work].ClientID =Zen.SuperQuote.dbo.tblCompany.CompanyIDWHERE[Work].WorkID = @WorkIDIF @Address1 IS NOT NULLSET @ReturnAddress = @ReturnAddress + @Address1 + CHAR(13)+ CHAR(10)RETURN @ReturnAddressENDHow can I get round this? By the way, I've rather simplified thefunction to ease readability. Also, I haven't posted any DDL because Idon't think that's the problem!ThanksEdward
View 2 Replies
View Related
May 30, 2007
Hi All,
Good Evening.
I need a comparision between Evaluation copy and Standard license version of SQL Server 2005 /SSIS.
I'm assigned a task to evaluate SSIS and migrate a project to SSIS.
I have downloaded SSIS evaluation version and started working on that.
Now i'm being posed questions for the complete functionality of the tool...
- Whether it has a Bulk load trasformation ?
- Whether the evaluation version contain all the features of a standard license version ?
I need to submit a consolidated report for SSIS in comparision to the current ETL tool features.
Can you please let me is there any considerable features not given with a evaluation copy ?
Thanks in advance,
Suresh N
View 4 Replies
View Related
Sep 17, 2007
In my table I have values like (2,3). I want to get the minimum value from the column
View 12 Replies
View Related
Aug 2, 2006
How do SQL 2000 service packs play a role in upgrading? That is, can SQL 2000 Standard with no Service Packs(SP) be upgraded to SQL 2005 Standard, or does SQL 2000 Standard have to have a certain service pack??
View 1 Replies
View Related
Apr 26, 2007
Hi All,How do I set just enough permissions on a database so that a developer cancreate new objects and modify them without giving him administratorprivilege. At the moment the db objects are dbo and execute permissions aregranted to indevidual through a schema.GRANT EXECUTE ON [dbo].[My_Prcsedure] TO [MySchema]Thanks
View 2 Replies
View Related
Dec 20, 2004
i need to create a dynamic field, which returns the minimum value of 2 fields.
A B C(i need)
500 600 500
350 250 250
825 950 825
select A,B,min(A,B) as C from MyTable
i know this query is wrong,
pls help me to solve this problem
RGDS
BAHA
View 4 Replies
View Related
Mar 15, 2007
How can I find the minimum value of column?
Select salonuid, avg(LPPA),[Find the minimum](LPPA) from kpi.dbo.employee_data group by salonuid
The Yak Village Idiot
View 2 Replies
View Related
May 5, 2006
How to find the minimum value from time Timestamp column ?
I want get the eralier timestamp vlaues from the avaliable list
when iam using Aggregate transformation ..its again giving all the list of vlaues
Thanks
Niru
View 4 Replies
View Related
Nov 12, 2014
I'm looking at the following Records:
cust_no item_no start_dt end_dt price
1060 2931 2011-02-06 9999-12-31 1.23
1060 2931 2011-04-18 9999-12-31 2.00
I want to be able to pull the records with the earliest date 2011-02-06 ...
There were other records with this same customer and item number. I used this script to return the two above.
select *
from price
where end_dt > getdate()
Now I need to add something so it only returns the record with the earliest date. I'm going to run this on a table that has many customer and item combinations.
View 3 Replies
View Related
Apr 13, 2015
I want the minimum of two values to be display like below without using the case
MIN(3.00,4.00)
output:
3.00
View 2 Replies
View Related
Jul 27, 2006
Hello,I need to select the minimum between the result of a function and anumber, but i can't find a smart way. By now I'm doing like thefollowing, but I think is very expensive because it evaluates thefunction twice:select case when (myfunction())<100 then (myfunction()) else 100 endAny idea is appreciated.Thank youRegards--elimina carraro per rispondere via email
View 4 Replies
View Related
Jun 20, 2007
Hi. I have an 'Attendance' table like this:PIN Year Category Days1 2006 Authorized 11 2006 Available 21 2006 Personal 32 2006 Authorized 42 2006 Available 52 2006 Personal 63 2006 Authorized 73 2006 Available 83 2006 Personal 94 2006 Authorized 104 2006 Available 114 2006 Personal 121 2007 Authorized 131 2007 Available 141 2007 Personal 152 2007 Authorized 162 2007 Available 172 2007 Personal 183 2007 Authorized 193 2007 Available 203 2007 Personal 214 2007 Authorized 224 2007 Available 234 2007 Personal 24I need to sum the days by PIN, Year and Category (that's easy...) ANDobtain a layout like this:PIN Auth 2006 Avail 2006 Pers 2006 Auth2007 Avail 2007 Pers 20071 1 23 13 14 152 4 56 16 17 183 7 89 19 20 214 10 1112 22 23 24How can I do this by queries without writing too many intermediatesteps ?What I have done is this (5 queries, 2, 3, and 4 building on top of1,and 5 building on 2, 3, 4).1 = Table1_Crosstab:TRANSFORM Sum(Table1.Days) AS SumOfDaysSELECT Table1.PIN, Table1.YearFROM Table1GROUP BY Table1.PIN, Table1.YearPIVOT Table1.Category;Then, based on that,2 = Authorized:TRANSFORM First([1 = Table1_Crosstab].Authorized) ASFirstOfAuthorizedSELECT [1 = Table1_Crosstab].PINFROM [1 = Table1_Crosstab]GROUP BY [1 = Table1_Crosstab].PINPIVOT [1 = Table1_Crosstab].Year;3 = Available:TRANSFORM First([1 = Table1_Crosstab].Available) AS FirstOfAvailableSELECT [1 = Table1_Crosstab].PINFROM [1 = Table1_Crosstab]GROUP BY [1 = Table1_Crosstab].PINPIVOT [1 = Table1_Crosstab].Year;and4 = Personal:TRANSFORM First([1 = Table1_Crosstab].Personal) AS FirstOfPersonalSELECT [1 = Table1_Crosstab].PINFROM [1 = Table1_Crosstab]GROUP BY [1 = Table1_Crosstab].PINPIVOT [1 = Table1_Crosstab].Year;and finally5 = AllSELECT [2 = Authorized].PIN, [2 = Authorized].[2006] AS [Auth 2006],[3 = Available].[2006] AS [Avail 2006], [4 = Personal].[2006] AS[Pers2006], [2 = Authorized].[2007] AS [Auth 2007], [3 = Available].[2007]AS [Avail 2007], [4 = Personal].[2007] AS [Pers 2007]FROM ([2 = Authorized] INNER JOIN [3 = Available] ON [2 =Authorized].PIN = [3 = Available].PIN) INNER JOIN [4 = Personal] ON[3= Available].PIN = [4 = Personal].PIN;It works, but... I am sure that this is an awkward way of doing it.Isthere any other, more elegant, way, please ? Besides, what if I hadnot 3, but 15 categories, for example ????Thanks a lot for your time reading this, Alex
View 4 Replies
View Related