I have a table with numbers and dates (1 number is not required on each date and date at regular intervals). When there is no number in the table, I would like to get the number of dates
Where am I:
to choose from (from the date of selection, where creep = 1 Order according to date range 2) F
I get this:
Date -------------- 2014-09-07 ------------- - 2014-07-26
Actually, I'm given this query dynamically: < / P>
Select * nums, where date is "2014-07-26" and second time, browse the entire table (why There was limited to the first 2 rows, but I compare 2 and 3 and 3 and 4 etc ...) The goal is to get it:
Date | Actual_number_of_real_dates_between_two_given_dates 2014-09-07 - 2014-07-26 | 20 2014-04-02 - 2014-02-12 | 13
etc ...
How can I do this? Thank you.
Edit:
What I have (just an example, dates and "shifre" are more complex):
Date | Chifera 2014-09-30 | 2 2014-09-29 | 1 2014-09-28 | 2 2014-09-27 | 2 2014-09-26 || 1 2014-09-25 | 2 2014-09-24 | 2
etc ...
What do I need for the number "1":
real_number_of_l_dates_betini_wo_given_dates 1 3
etc ...
Edit 2:
My updated query for Gordon Linoff Thanks
Count (n. IDs), as the nums n internal added (select min (date) as D1, max (date) to d2 (select dates from where chiffre = 1 date range up to range 2) D ) DD where between DD and n.date.d1 Dd.d2
How can I check line 2 with 3? 4 with 4 etc ... not only the last 2? Should I Use A Loop? Or I can do without it
What is it for you to do?
as numdeates, (datediff (dd.d2, dd.d1) + 1) select the count as (different n.date), date interval, (datediff (dd.d2) , Dd.d1) + 1- as the unavailable digits in the form of count (dated to dated date)) d1 between ds.d1 and dd as n.date as d2, date ('2014-09 -07 ') in the form of nums n cross join (select date (' 2014-07-26 ') d2;
Edit:
Want two dates:
Select the number (separate n.date) as numdates, (dd.d2, dd.d1) + 1) Reverse interval is missing as datediff (dd.d2, dd.d1) + 1 - count (separate n.date)) as nums n cross join (select min (date) as D1, maximum (date) From d2 (choose date from serial number according to date date range) 2) DD where ndate between dd.d1 and dd.d2;
Comments
Post a Comment