I have a Collectionview(iPad) with
flow layout
Scroll direction: horizonlal
3 items at Y and 7 items at X
Possible Device-Orientation is only Landscape.
The normal sorting is like this(one page):
01 04 07 10 13 16 19
02 05 08 11 14 17 20
03 06 09 12 15 18 21
But i need a sorting like this:
act. page............................next page
01 02 03 04 05 06 07 | 22 23 24 25 26 27 28
08 09 10 11 12 13 14 | 29 30 31 32 33 34 35
15 16 17 18 19 20 21 | 36 37 38 39 40
Is it possible to change the item-position with custom-layout?
I tried to sort the data source pagewise like 01, 08, 15 ... but this dont help if jump to an entry middle of such a page and at all i cannot use sections.
Related
I would like to get the first and the last value in the column Status1 of each sequence of the same value!
This is an example of my table:
time Status1 Eficiencia Lote
----------------------------------------------------
2020 06 14 18:03:48.457 70 80 95
2020 06 14 18:04:47.693 70 80 95
2020 06 14 18:06:58.203 55 80 95
2020 06 14 18:08:19.900 55 80 95
2020 06 14 18:09:45.537 55 80 95
2020 06 14 18:10:06.670 100 80 13
2020 06 14 18:10:27.297 100 80 13
2020 06 14 18:10:31.810 100 80 13
2020 06 14 18:10:43.187 100 80 13
2020 06 14 18:11:30.303 55 80 14
2020 06 14 18:12:07.563 55 80 14
2020 06 14 18:18:54.997 55 80 14
I tried this but using this I didn't get by each sequence but in the hole table!
;with cte as
(
select
*,
RnAsc = row_number() over (partition by [Status1] order by time),
RnDesc = row_number() over (partition by [Status1] order by time desc)
from
[VALORES_DB].[dbo].[OEE_TESTE]
)
select time, [Status1], Eficiencia, Lote, Status1
from cte
where RnAsc = 1 or RnDesc = 1
I would like to get the follow:
time Status1 Eficiencia Lote
------------------------------------------------------
2020 06 14 18:03:48.457 70 80 95
2020 06 14 18:04:47.693 70 80 95
2020 06 14 18:06:58.203 55 80 95
2020 06 14 18:09:45.537 55 80 95
2020 06 14 18:10:06.670 100 80 13
2020 06 14 18:10:43.187 100 80 13
2020 06 14 18:11:30.303 55 80 14
2020 06 14 18:18:54.997 55 80 14
I would suggest lag() and lead():
select t.*
from (select t.*,
lag(status1) over (order by time) as prev_status1,
lead(status1) over (order by time) as next_status1
from t
) t
where (prev_status1 is null or prev_status1 <> status1) or
(next_status1 is null or next_status1 <> status1);
These comparisons determine where the value changes -- which is really what you are asking for.
I would like to generate this sequence
col sequence
01 01
01 02
01 03
01 04
01 05
02 01
02 02
02 03
02 04
02 05
..
..
12 01
12 02
12 03
12 04
12 04
And add this as a sequence to another select.
Hierarchical query might help to produce result you posted:
SQL> with
2 c1 as
3 (select lpad(1 + level - 1, 2, '0') col1
4 from dual
5 connect by level <= 12
6 ),
7 c2 as
8 (select lpad(1 + level - 1, 2, '0') col2
9 from dual
10 connect by level <= 5
11 )
12 select c1.col1, c2.col2
13 from c1 cross join c2
14 order by c1.col1, c2.col2;
CO CO
-- --
01 01
01 02
01 03
01 04
01 05
02 01
02 02
02 03
02 04
02 05
03 01
03 02
<snip>
11 04
11 05
12 01
12 02
12 03
12 04
12 05
60 rows selected.
SQL>
You want row_numner() :
select col, row_number() over (partition by col order by col) as sequence
from table t;
You can use sub-query for further operation.
In my line of work, rollup refers to combining/averaging months or quarters. In this case, the rollup is based on INDCODE and PERIOD. I have a table named INDUSTRY that contains data from quarters 1, 2, 3, and 4. Below is a sample of what it looks like.
State area periodyear period indcode firms avgemp
32 000001 2016 01 447125 25 412
32 000001 2016 02 447125 28 427
32 000001 2016 03 447125 29 429
32 000001 2016 04 447125 26 385
First, I am trying to average certain fields but not all. In this case, it would be firms and avgemp. If I was wanting it to look like the desired result below, can I use the rollup function? I want the new averaged data to be in the same table as quarters 1, 2, 3, and 4. Is it better to put the averaged data in a new table?
State area periodyear period indcode firms avgemp
32 000001 2016 01 447125 25 412
32 000001 2016 02 447125 28 427
32 000001 2016 03 447125 29 429
32 000001 2016 04 447125 26 385
32 000001 2016 00 447125 27 413
I would like to return rolling 12 month averages for each month in a resulting dataset but am not sure how I can do this.
I thought the following script would work:
DECLARE #StartDate as datetime
DECLARE #EndDate as datetime
SET #StartDate = '01/04/2011'
SET #EndDate = getdate()
select x.FinYear, x.FinMonth, x.MonthText, avg(TimeSeconds) [AverageTimeSeconds]
from times x
where (x.TimeOfCall >= #StartDate and x.TimeOfCall < #EndDate)
group by x.FinYear, x.FinMonth, x.MonthText
order by x.FinYear, x.FinMonth
but it only returns the monthly averages, how do I get the 12 month average leading up to each of the months between the start and end date.
The resulting dataset I am looking for is as follows:
Fin Year Fin Month Month Text Avg Time Seconds R12M Avg Seconds
2015/16 01 Apr 100 101
2015/16 02 May 95 98
2015/16 03 Jun 103 100
2015/16 04 Jul 110 100
2015/16 05 Aug 100 100
2015/16 06 Sep 90 97
2015/16 07 Oct 93 97
2015/16 08 Nov 98 100
2015/16 09 Dec 80 98
2015/16 10 Jan 88 98
2015/16 11 Feb 100 98
2016/17 12 Mar 115 100
2016/17 01 Apr 105 100
2016/17 02 May 98 100
2016/17 03 Jun 95 98
2016/17 04 Jul 102 98
2016/17 05 Aug 109 99
2016/17 06 Sep 104 100
2016/17 07 Oct 98 98
2016/17 08 Nov 99 97
2016/17 09 Dec 90 97
the rolling 12 month average is not an average of the monthly averages but an average of the 12 months leading up to the month in question. So January 2017 would be the average of 01 February 2016 - 31 January 2017 and October 2016 would be 01 November 2015 to 31 October 2016.
I hope you can help :-) .
If you have data for every month, then the following calculates the average over the preceding 12 months (note this is the overall average, not the average of the monthly averages):
select x.FinYear, x.FinMonth, x.MonthText, avg(TimeSeconds)as [AverageTimeSeconds],
(sum(sum(TimeSeconds)) over (order by x.FinYear, x.FinMonth rows between 11 preceding and current row) /
sum(count(*)) over (order by x.FinYear, x.FinMonth rows between 11 preceding and current row)
) as avg_12month
from times x
where x.TimeOfCall >= #StartDate and x.TimeOfCall < #EndDate
group by x.FinYear, x.FinMonth, x.MonthText
order by x.FinYear, x.FinMonth;
Note: The where clause affects the 12-month look-back period. In other worse, the look-back will not include months before this period.
I have two text boxes. The first contains this text just like shown.
I need to remove the first 7 characters of each row then show the edited text in the second box.
The first number is different every time so I can't use this
RawText.Text = Replace(RawText.Text, "1757792", " ")
TextFilter.Text = RawText.Text
because the number changes every row.
Is there a way to have a button remove ALL instances of ANY text 7 characters long?
1757792 02 08 09 10 15 21 22 29 34 40 44 46 47 48 53 56 58 68 69 71
1757793 01 07 16 20 22 25 30 36 38 39 42 48 49 51 58 66 70 72 79 80
1757794 01 02 07 09 10 18 29 32 35 36 48 53 54 56 62 65 68 69 71 73
1757795 01 02 06 09 12 18 23 27 30 35 43 52 57 59 60 61 62 73 74 76
1757796 01 11 13 14 18 19 22 31 34 41 45 46 54 57 61 70 71 72 79 80
1757797 01 08 10 18 19 21 32 41 43 44 45 54 61 62 64 66 68 73 74 80
1757798 02 03 06 09 10 23 27 28 33 36 38 41 49 53 60 61 64 73 74 80
1757799 02 12 16 34 36 44 51 52 55 57 58 59 64 71 73 75 76 78 79 80
1757800 05 11 13 17 18 19 23 24 27 31 34 38 39 45 48 61 67 73 79 80
1757801 17 23 29 31 35 38 43 45 48 51 56 57 60 64 65 66 67 73 77 78
1757802 05 06 11 14 17 20 21 27 28 29 33 41 45 49 58 66 67 73 79 80
1757803 06 07 10 11 12 19 20 21 25 30 33 35 38 42 46 51 65 66 75 80
1757804 06 14 16 19 20 23 32 42 43 44 48 52 62 67 68 69 71 72 74 78
You can use string methods like Substring. If you really want to remove the first 7 you can use String.Substring:
Dim txt2Lines = From l In RawText.Lines
Let index = Math.Min(l.Length, 7)
Select l.Substring(index)
txt2.Lines = txt2Lines.ToArray()
This handles also the case that there are also shorter lines.
Note that it doesn't remove the leading space since that is not part of the first seven characters. You could use l.Substring(index).TrimStart().
Another approach is to search the first space and remove everything before that:
Dim txt2Lines = From l In RawText.Lines
Let index = Math.Max(l.IndexOf(" "), 0)
Select l.Substring(index)
txt2.Lines = txt2Lines.ToArray()
String.IndexOf returns -1 if the substring wasn't found, that's why i've used Math.Max(l.IndexOf(" "), 0). In that case the full line should be taken.
You could use String.Split to split the text at the vbCrLf (line break), then use String.SubString to select the string parter starting at index 8, and there you are.
And as GSerg pointed out, if you would like to replace all 7 digit occurences try this:
Dim ResultString As String
Try
ResultString = Regex.Replace(SubjectString, "\d{7}", "", RegexOptions.Singleline)
Catch ex As ArgumentException
'Syntax error in the regular expression
End Try