Guys this is brilliant,
its not quite what i needed, but it is better than that because i had to go fix it and i learnt something!
Thanks alot. Really appreciate it.
sorry my query should have also included ID = 'foo1'
SELECT ID, floor(rawdateandtime/900000)*900000 as flooredDate, rawdateandtime, Value
FROM TBL1
WHERE ID = 'foo1'
AND RawDateAndTime BETWEEN 1243810896000 AND 1243821696000
ok below is a COMPLETE three hours of example data. If you were to run my original query against this it would return 12 rows, one for each of the 15 minute intervals between midnight and 02:59 (on the 01/06/2009).
My problem occurs when one of these rows is missing, and i need to return some...
makros: ah ok, i understand whats going on there now. Unfortunately the interval i have is a large interval spanning at least a day. Thankyou for your input though, it may well help me figure this out.
bborissov: I understand your query (which is a miracle for me) and i see what you are trying...
Thanks for the reply markros,
I am trying to understand your query and i believe you are trying to output each id where a floored rawdateandtime value exists between the two given date values.
however i think i have explained myself badly.
What i meant was: supposing my table had rows...
Hi,
I am using a MSSQL database, and I am trying to select records from a db based on a 15 minute interval. The Date is recorded as a millisecond epoch time (stored as a numeric) which I round down to the nearest 15 minute window within the hour:
SELECT ID, floor(rawdateandtime/900000)*900000...
Is there an easy way of returning specified rows that have no index column?
I basically want to create a queries that only returns rows in blocks of 20 for example.
any ideas?
Is there any neat way i can combine the following two statements to return me a single table of results with the columns:
lt2, lt3, id
select count(*) lt2,id
FROM TABLE
where Value<2
GROUP BY id
select count(*) lt3,id
FROM TABLE
where Value<3
GROUP BY id
Thanks for your help
tommot82
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.