Questions tagged [difference-between-rows]

14 questions
61
votes
2 answers

Calculate Time Difference Between Two Rows

I have a table that contains the following: DataDate Value 2010-03-01 08:31:32.000 100 2010-03-01 08:31:40.000 110 2010-03-01 08:31:42.000 95 2010-03-01 08:31:45.000 101 . . . . . …
amarcy
  • 1,485
  • 2
  • 19
  • 28
3
votes
3 answers

SQL To find difference between multiple rows

I have a table containing multiple records for different transactions i.e. ID Date REF 1 01/09/2008 A 1 11/09/2008 A 1 01/10/2008 A 2 01/09/2008 A 2 01/10/2008 A 2 01/11/2008 B 2 01/12/2008 B and I'm looking to…
Mark Roberts
1
vote
1 answer

How to calculate the differences between the adjacent elements from two vectors?

I want to calculate the differences between of the Nth value of the vector X and the N-1th value of the vector Y. All I know is the function delta, but it can only work within one vector. Does anyone know a better method? Thanks in advance.
1
vote
2 answers

How to return Dates between in format year-months?

Is there a way to return dates between in format year-months in Cognos reports? Example: I've been using the following to figure out "age" _years_between (current_date, [DateOfBirth]). Result comes out as just the age in years. I'm looking for a…
1
vote
2 answers

Difference between nrow and length in for loop?

It might be a stupid question, but I dont seem to understand why the nrow and length vectors are behaving differently. Example: #Create a dummy data frame dff = data.frame(X = c(35,18,17,35), Y =c(1,2,3,4)) #Test whether 1:nrow(dff) and…
janman
  • 35
  • 7
1
vote
1 answer

PHP Mysql Get Gap between time range

Im kinda new here in stackoverflow. Anyway here is my problem, hope someone could help me on this. I have a table in mysql see below Start Time End Time Date 9:00 10:00 2016-02-26 9:00 10:00 …
0
votes
2 answers

New row which is the difference of two rows using Groupby in a pandas dataframe

I have a dataframe import pandas as pd df = pd.DataFrame({ 'ID': [1, 1, 1, 2, 2, 2], 'value': [100, 120, 130, 200, 190, 210], 'value2': [2100, 2120, 2130, 2200, 2190, 2210], 'state': ['init','mid', 'final', 'init', 'mid', 'final'], }) I want…
0
votes
2 answers

Problem on MySQL Query on Between Operator with php

I have MySQL table "room_booking" and this table contain two columns 'start_time' and 'end_time'. I want to check the time of the conference room booking. Suppose that if room is booked from 2:10 PM to 3:15 PM. Then another entry should not insert…
Paras Purwar
  • 1
  • 1
  • 2
0
votes
4 answers

ACCESS/SQL: Calculating the difference between rows (not dates)

I looked through the questions here but didn't find one that suited my case. I'm trying to write a query that will output the difference between rows Here is a table: ITEM CYCLES -------------------- itemA 5 itemA 17 itemA 20 …
Christian M
  • 235
  • 4
  • 11
  • 18
0
votes
1 answer

get previous week date in select query

I have below query which i am using for reporting in Cognos. I am doing reporting every week on Monday for the previous week from Monday till Sunday. Currently this date is hardcoded but i want to make it dynamic so that everytime when i run this…
Andrew
  • 3,632
  • 24
  • 64
  • 113
0
votes
6 answers

SQL Select Concat between 2 numbers

I work with SQL Server 2012 and need a concatenate between 2 different columns. eg: 3 and 7 = 34567 or 1 and 4 = 1234 or 2 and 2 = 2 When I use the Concat Function, I am just able to Concate the first and the last number. But I need the numbers…
0
votes
1 answer

Firebird query selecting previous row

who can help me with my query? here's the screenshot of the table. i want to compute the range/minutes between two dates. My idea is to subtract the second row of FORMATTED_DATEMODIFIED to first row of FORMATTED_DATEMODIFIED and so on. i want to…
aiipee
  • 252
  • 3
  • 9
  • 18
0
votes
2 answers

Dropping out the last rows in data frame

I have a data frame which could be approximated by the following example df: a <- seq(1, 1010, 1) b <- seq(2,1011,1) c <- c(rep(1,253), rep(2, 252), rep(3,254), rep(4,251)) d <- c(rep(5,253), rep(6, 252), rep(7,254), rep(8,251)) df <-…
-4
votes
4 answers

I need SQL query to find between two date and another column by name

SELECT * FROM claz WHERE student AND (BETWEEN date AND date) I have this one table claz, and I need to search to find student records between date periods