I want to find the average of the grouped values
with the rule (if time(n+1) - time(n) < 40 minutes) and by feature
<style type="text/css">
.tg {border-collapse:collapse;border-spacing:0;}
.tg td{border-color:black;border-style:solid;border-width:1px;font-family:Arial, sans-serif;font-size:14px;
overflow:hidden;padding:10px 5px;word-break:normal;}
.tg th{border-color:black;border-style:solid;border-width:1px;font-family:Arial, sans-serif;font-size:14px;
font-weight:normal;overflow:hidden;padding:10px 5px;word-break:normal;}
.tg .tg-0pky{border-color:inherit;text-align:left;vertical-align:top}
</style>
<table class="tg">
<thead>
<tr>
<th class="tg-0pky">feature</th>
<th class="tg-0pky">value</th>
<th class="tg-0pky">time</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tg-0pky">Diameter</td>
<td class="tg-0pky">59,76</td>
<td class="tg-0pky">20200508 11:13:06</td>
</tr>
<tr>
<td class="tg-0pky">Diameter</td>
<td class="tg-0pky">59,69</td>
<td class="tg-0pky">20200508 11:13:13</td>
</tr>
<tr>
<td class="tg-0pky">Diameter</td>
<td class="tg-0pky">59,94</td>
<td class="tg-0pky">20200508 11:13:20</td>
</tr>
<tr>
<td class="tg-0pky">Diameter</td>
<td class="tg-0pky">59,73</td>
<td class="tg-0pky">20200508 11:13:27</td>
</tr>
<tr>
<td class="tg-0pky">Diameter</td>
<td class="tg-0pky">59,79</td>
<td class="tg-0pky">20200508 12:16:55</td>
</tr>
<tr>
<td class="tg-0pky">Diameter</td>
<td class="tg-0pky">59,76</td>
<td class="tg-0pky">20200508 12:17:03</td>
</tr>
<tr>
<td class="tg-0pky">Diameter</td>
<td class="tg-0pky">60,1</td>
<td class="tg-0pky">20200508 12:17:10</td>
</tr>
<tr>
<td class="tg-0pky">Diameter</td>
<td class="tg-0pky">59,95</td>
<td class="tg-0pky">20200508 12:17:18</td>
</tr>
<tr>
<td class="tg-0pky">Diameter</td>
<td class="tg-0pky">60,02</td>
<td class="tg-0pky">20200508 12:17:36</td>
</tr>
<tr>
<td class="tg-0pky">Weight</td>
<td class="tg-0pky">9,1</td>
<td class="tg-0pky">20200508 05:23:30</td>
</tr>
<tr>
<td class="tg-0pky">Weight</td>
<td class="tg-0pky">9,08</td>
<td class="tg-0pky">20200508 05:23:35</td>
</tr>
<tr>
<td class="tg-0pky">Weight</td>
<td class="tg-0pky">9,04</td>
<td class="tg-0pky">20200508 05:23:40</td>
</tr>
<tr>
<td class="tg-0pky">Weight</td>
<td class="tg-0pky">9,06</td>
<td class="tg-0pky">20200508 05:23:46</td>
</tr>
<tr>
<td class="tg-0pky">Weight</td>
<td class="tg-0pky">9,16</td>
<td class="tg-0pky">20200508 05:23:52</td>
</tr>
<tr>
<td class="tg-0pky">Weight</td>
<td class="tg-0pky">9,69</td>
<td class="tg-0pky">20200508 06:03:05</td>
</tr>
<tr>
<td class="tg-0pky">Weight</td>
<td class="tg-0pky">9,65</td>
<td class="tg-0pky">20200508 06:03:13</td>
</tr>
<tr>
<td class="tg-0pky">Weight</td>
<td class="tg-0pky">9,64</td>
<td class="tg-0pky">20200508 06:03:18</td>
</tr>
<tr>
<td class="tg-0pky">Weight</td>
<td class="tg-0pky">9,39</td>
<td class="tg-0pky">20200508 06:03:24</td>
</tr>
<tr>
<td class="tg-0pky">Weight</td>
<td class="tg-0pky">9,44</td>
<td class="tg-0pky">20200508 06:03:29</td>
</tr>
</tbody>
</table>
I have tried to do something like this:
I tried something like:
SELECT avg(ISNULL(Value,0)), feature FROM V_Value GROUP BY (SELECT avg(Value) from V_Value t1, V_Value t2 where DATEDIFF(minute,t1.DateMis+t1.HourMis,t2.DateMis+t2.HourMis) <= '40' ) order by feature
but it don't work. returns an error on the group by clause
groupings should be:
because every 40 minutes he groups the values of the same feature
the result should be:
Diameter | 59,78
Diameter | 59,924
Weight | 9,088
Weight | 9,562
I took a while to solve this but after some googling and trying stuff I reached this solution.
It rounds the datime down to the desired precision (in this case 40min), and used this rounded time as a grouping column.
SELECT
[rounded_time]
,[feature]
,AVG([value]) AS [value]
FROM (
SELECT
[time]
,DATEADD(mi, DATEDIFF(mi, 0, [time])/40*40, 0) as [rounded_time]
,[feature]
,[value]
FROM V_Value
) as x
To explain what it does you can see the following code sample, it will explain it better than word
DECLARE #SampleData TABLE
(TimeCol Datetime
)
INSERT INTO #SampleData VALUES
('2020-06-04 17:00:00'),('2020-06-04 17:05:00'),('2020-06-04 17:10:00')
,('2020-06-04 17:15:00'),('2020-06-04 17:20:00'),('2020-06-04 17:25:00')
,('2020-06-04 17:30:00'),('2020-06-04 17:35:00'),('2020-06-04 17:40:00')
,('2020-06-04 17:45:00'),('2020-06-04 17:50:00'),('2020-06-04 17:55:00')
,('2020-06-04 18:00:00'),('2020-06-04 18:05:00'),('2020-06-04 18:10:00')
,('2020-06-04 18:15:00'),('2020-06-04 18:20:00'),('2020-06-04 18:25:00')
,('2020-06-04 18:30:00'),('2020-06-04 18:35:00'),('2020-06-04 18:40:00')
SELECT
[TimeCol] AS [Source_Time]
,DATEDIFF(mi, 0, [TimeCol]) AS [MinSince1900] --minutes since 1900-01-01 00:00
,DATEDIFF(mi, 0, [TimeCol])/40*40 AS [MinSince1900_Rounded] --integer divison truncates the decimal part, therefore the result is always rounded down (in this case in blocks of 40min)
,DATEADD(mi, DATEDIFF(mi, 0, [TimeCol])/40*40, 0) AS [Rounded_Time]--add the above minutes back to 1900-01-01 00:00 and you get your grounded datetime
FROM #SampleData
I wanted to know how to display the data by reading a local json. In a row having 4 columns, 2 columns are coming from 1 array and 2 are coming from a different array.
HTML:
<table class="table table-striped table-bordered">
<thead>
<tr>
<th></th>
<th>IT</th>
<th>IT User</th>
<th>CT</th>
<th>CT User</th>
</tr>
</thead>
<tbody>
<tr>
<td class="currency">Type A</td>
<td class="currency"></td>
<td class="currency"></td>
<td class="currency"></td>
<td class="currency"></td>
</tr>
<tr>
<td class="currency">Type B</td>
<td class="currency"></td>
<td class="currency"></td>
<td class="currency"></td>
<td class="currency"></td>
</tr>
</tbody>
JSON:
{
"intr_liab":[
{
"ty":"typeA",
"it":"100",
"ct":"200"
},
{
"ty":"typeAITUser",
"it":"300",
"ct":"400"
},
{
"ty":"typeB",
"it":"500",
"ct":"600"
},
{
"ty":"typeBITUser",
"it":"700",
"ct":"800"
}
]
}
So data in the table should come as:
<body ng-controller="MainCtrl">
<table class="table table-striped table-bordered">
<thead>
<tr>
<th></th>
<th>IT</th>
<th>IT User</th>
<th>CT</th>
<th>CT User</th>
</tr>
</thead>
<tbody>
<tr>
<td class="currency">Type A</td>
<td class="currency">100</td>
<td class="currency">300</td>
<td class="currency">200</td>
<td class="currency">400</td>
</tr>
<tr>
<td class="currency">Type B</td>
<td class="currency">500</td>
<td class="currency">700</td>
<td class="currency">600</td>
<td class="currency">800</td>
</tr>
</tbody>
</table>
</body>
Please refer this Plunker for more clarity:
https://plnkr.co/edit/USt7nXmwCTRcCfOx8sma
Please replace the HTML code with following. I hope it will help you.
<body ng-controller="MainCtrl">
<table class="table table-striped table-bordered">
<thead>
<tr>
<th></th>
<th>IT</th>
<th>IT User</th>
<th>CT</th>
<th>CT User</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="item in intLiab">
<td class="currency">{{item.ty}}</td>
<td class="currency">{{item.it}}</td>
<td class="currency"></td>
<td class="currency">{{item.ct}}</td>
<td class="currency"></td>
</tr>
</tbody>
</table>
</body>
Please comment if you need more specific answer.
I have a table where I use ng-repeat and angular-ui collapse to show data on it. I would like to implement ui-grid, but I'm not even near a solution.
Here's a Plunker of my code: https://plnkr.co/edit/mKeRaDv22WzBXjRT67oO?p=preview
The html code:
<div ng-controller="MyCtrl">
<table class="table table-striped">
<thead>
<tr>
<th style="width: 20%">A: </th>
<th style="width: 20%">B: </th>
<th style="width: 15%">C: </th>
<th style="width: 15%">D: </th>
<th style="width: 15%">E: </th>
<th style="width: 15%">F: </th>
</tr>
</thead>
<tbody ng-repeat="data in myData" ng-click="element.isCollapsed = !element.isCollapsed">
<tr>
<td>{{data.a}}</td>
<td>{{data.b}}</td>
<td>{{data.c}}</td>
<td>{{data.d}}</td>
<td>{{data.e}}</td>
<td>{{data.f}}</td>
<td></td>
</tr>
<tr collapse="element.isCollapsed" ng-show="element.isCollapsed">
<td colspan="2">{{data.g}} </td>
<td colspan="2">{{data.h}} </td>
<td colspan="2">{{data.i}} </td>
</tr>
<tr collapse="element.isCollapsed" ng-show="element.isCollapsed">
<td colspan="2">{{data.j}} </td>
<td colspan="2">{{data.k}} </td>
<td colspan="2">{{data.l}} </td>
</tr>
<tr collapse="element.isCollapsed" ng-show="element.isCollapsed">
<td colspan="6">{{data.m}} </td>
</tr>
</tbody>
</table>
</div>
I am new to selenium and I have this question where I need to loop through a table and get the values in that table
<table>
<tr>
<td style="width:5px">
</td>
<td>
<table class="reportTable" id="Allocations">
<tbody>
<tr class="table_header">
<td style="width:5px;">
<img class="HideImage" src="Images/minus.gif" alt="Hide Details">
</td>
<td style="width:33%">
Channel of Trade</td>
<td style="width:33%">
PILOT TRAVEL CENTE-122194-W/S - UNB Contract</td>
<td style="width:33%">
<span id="TruckLoading_10142602_Info" style="COLOR: white;text-decoration:underline;cursor:pointer">
Trucks loading - 0</span>
</td>
</tr>
<tr>
<td style="width:5px;">
</td>
<td colspan="3">
<table rules="rows" class="reportTable" font-family="Tahoma" pagerstyle-visible="False" id="TerminalGrid" border="1">
<tbody>
<tr class="productlabel2" align="left">
<td scope="col" style="width:5px;">
</td>
<td>
Product Details</td>
</tr>
<tr class="hdr2">
<td scope="col" style="width:5px;">
</td>
<td scope="col">
Fuel Type</td>
</tr>
<tr class="FuelTypeHeader">
<td style="width:5px;border:none" onclick="ShowHideDetails(this)">
<img class="HideImage" src="Images/minus.gif" alt="Hide Details" id="Fuel_Img">
</td>
<td style="border-left:none;border-right:none; padding-left:3px">
<table id="C_V" style="width:100%;border-collapse:collapse; border:none; padding:0px 0px 0px 0px; margin:0px 0px 0px 0px;">
<tbody>
<tr>
<td style="width:20em;">
<span>
DSL - LSD/ULSD</span>
</td>
<td style="width:60em;">
<span id="CVSpan">
<span style="margin-right:10px">
<span style="float:left;padding-top:3px">
Currently:</span>
<span style="float:left;width:6em;padding-top:2px; margin-left:5px; margin-right:5px;margin-top:2px;padding-bottom:2px; text-align:center; background-color:#00FF00;">
Available</span>
<span style="float:left; padding-top:3px">
<b>
30,839</b>
gallons remaining until Mon 8/1/2016 12:00:00 AM CDT</span>
</span>
</span>
</td>
<td align="right">
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr style="">
<td style="width:5px;">
</td>
<td>
<table id="ProdDetails" rules="all" pagerstyle-visible="False" style="width: 100%" border="1">
<tbody>
<tr class="table_header2">
<th scope="col">
Nominated Volume</th>
<th scope="col">
Allocation Period</th>
<th scope="col">
Allocation %</th>
<th scope="col">
Allocation Start Amt</th>
<th scope="col">
Allocation Lifted</th>
<th scope="col">
Allocation Remaining</th>
<th scope="col">
GPO Allowance</th>
<th scope="col" class="center width8em">
GPO Remaining</th>
<th scope="col">
Category Status</th>
<th scope="col">
Ratability Status</th>
<th scope="col">
Next Scheduled Refresh Date</th>
<th scope="col">
Reference ID</th>
</tr>
<tr class="tablerow2">
<td class="right width8em">
41,118</td>
<td class="center width10em">
Daily</td>
<td class="right">
75%</td>
<td class="right">
30,839</td>
<td class="right">
0</td>
<td class="right">
30,839</td>
<td class="right">
0</td>
<td class="right width8em bold" id="GPO_Rmd">
0
</td>
<td class="center" style="background-color:#00FF00;">
Available</td>
<td class="center" style="background-color:#0099CC;">
Below Trend</td>
<td class="center width20em">
8/1/2016 12:00:00 AM CDT</td>
<td class="center width20emWordWrap">
DSL - LSD/ULSD</td>
</tr>
<tr class="tablerow2">
<td class="right width8em">
287,826</td>
<td class="center width10em">
Weekly</td>
<td class="right">
125%</td>
<td class="right">
359,783</td>
<td class="right">
114,083</td>
<td class="right">
245,700</td>
<td class="right">
0</td>
<td class="right width8em bold" id="GPO_Rmd">
0
</td>
<td class="center" style="background-color:#00FF00;">
Available</td>
<td class="center" style="background-color:#0099CC;">
Below Trend</td>
<td class="center width20em">
8/4/2016 12:00:00 AM CDT</td>
<td class="center width20emWordWrap">
DSL - LSD/ULSD</td>
</tr>
<tr class="tablerow2">
<td class="right width8em">
1,233,540</td>
<td class="center width10em">
Monthly</td>
<td class="right">
115%</td>
<td class="right">
1,418,571</td>
<td class="right">
1,361,264</td>
<td class="right">
57,307</td>
<td class="right">
0</td>
<td class="right width8em bold" id="GPO_Rmd">
0
</td>
<td class="center" style="background-color:#FFFF00;">
Low</td>
<td class="center" style="background-color:#00CC00;">
On Track</td>
<td class="center width20em">
8/1/2016 12:00:00 AM CDT</td>
<td class="center width20emWordWrap">
DSL - LSD/ULSD</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr id="GPO_Row">
<td style="width:5px;">
</td>
<td>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr class="table_header">
<td style="width:5px;" onclick="ShowHideDetails(this)">
<img class="HideImage" src="Images/minus.gif" alt="Hide Details">
</td>
<td style="width:33%">
Channel of Trade</td>
<td style="width:33%">
PILOT TRAVEL CENTE-122194-W/S - UNB Fwrd Cont</td>
<td style="width:33%">
<span id="TruckLoading_17049566_Info" style="COLOR: white;text-decoration:underline;cursor:pointer" onclick="GetTruckLoadingInformationJS(this,17049566);">
Trucks loading - 0</span>
</td>
</tr>
<tr>
<td style="width:5px;">
</td>
<td colspan="3">
<table rules="rows" class="reportTable" font-family="Tahoma" pagerstyle-visible="False" id="TerminalGrid" border="1">
<tbody>
<tr class="productlabel2" align="left">
<td scope="col" style="width:5px;">
</td>
<td>
Product Details</td>
</tr>
<tr class="hdr2">
<td scope="col" style="width:5px;">
</td>
<td scope="col">
Fuel Type</td>
</tr>
<tr class="FuelTypeHeader">
<td style="width:5px;border:none" onclick="ShowHideDetails(this)">
<img class="HideImage" src="Images/minus.gif" alt="Hide Details" id="Fuel_Img">
</td>
<td style="border-left:none;border-right:none; padding-left:3px">
<table id="C_V" style="width:100%;border-collapse:collapse; border:none; padding:0px 0px 0px 0px; margin:0px 0px 0px 0px;">
<tbody>
<tr>
<td style="width:20em;">
<span>
DSL - LSD/ULSD</span>
</td>
<td style="width:60em;">
<span id="CVSpan">
<span style="margin-right:10px">
<span style="float:left;padding-top:3px">
Currently:</span>
<span style="float:left;width:6em;padding-top:2px; margin-left:5px; margin-right:5px;margin-top:2px;padding-bottom:2px; text-align:center; background-color:#FF0000;">
Out</span>
<span style="float:left; padding-top:3px">
<b>
0</b>
gallons remaining until Mon 8/1/2016 12:00:00 AM CDT</span>
</span>
</span>
</td>
<td align="right">
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr style="">
<td style="width:5px;">
</td>
<td>
<table id="ProdDetails" rules="all" pagerstyle-visible="False" style="width: 100%" border="1">
<tbody>
<tr class="table_header2">
<th scope="col">
Nominated Volume</th>
<th scope="col">
Allocation Period</th>
<th scope="col">
Allocation %</th>
<th scope="col">
Allocation Start Amt</th>
<th scope="col">
Allocation Lifted</th>
<th scope="col">
Allocation Remaining</th>
<th scope="col">
GPO Allowance</th>
<th scope="col" class="center width8em">
GPO Remaining</th>
<th scope="col">
Category Status</th>
<th scope="col">
Ratability Status</th>
<th scope="col">
Next Scheduled Refresh Date</th>
<th scope="col">
Reference ID</th>
</tr>
<tr class="tablerow2">
<td class="right width8em">
0</td>
<td class="center width10em">
Custom 1 day(s)</td>
<td class="right">
100%</td>
<td class="right">
0</td>
<td class="right">
0</td>
<td class="right">
0</td>
<td class="right">
0</td>
<td class="right width8em bold" id="GPO_Rmd">
0
</td>
<td class="center" style="background-color:#FF0000;">
Out</td>
<td class="center" style="background-color:#0099CC;">
Below Trend</td>
<td class="center width20em">
8/1/2016 12:00:00 AM CDT</td>
<td class="center width20emWordWrap">
MERC-DSL</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr id="GPO_Row">
<td style="width:5px;">
</td>
<td>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</table>
I wanted to know how to loop the table so i can get a contracts that's the " PILOT TRAVEL CENTE-122194-W/S - UNB Contract","PILOT TRAVEL CENTE-122194-W/S - UNB Fwrd Cont" and "UNB Spot" along with the data of the table also.
Thanks in advance.
Ok you didn't say nothing about the language you use so i will give you example in C#
//Init table element (in this case by tag name but better chose by id or Name)
IWebElement tableElement = driver.FindElement(By.TagName("table"));
//Init TR elements from table we found into list
IList<IWebElement> trCollection = tableElement.FindElements(By.TagName("tr"));
//define TD elements collection.
IList<IWebElement> tdCollection;
//loop every row in the table and init the columns to list
foreach(IWebElement element in trCollection)
{
tdCollection = element.FindElements(By.TagName("td"));
//now in the List you have all the columns of the row
string column1 = tdCollection[0].Text;
string column2 = tdCollection[1].Text;
...
}
if you use other language just change the syntax the logic is the same.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I am new to Angularjs and i want to show top 5 and bottom 5 rows in between click all functionality which shows all the records. I tried different things but not able to get success.
<div class="col-md-12">
<div class="dataTables_wrapper" id="comparison-table">
<table class="datatable">
<thead>
<tr>
<th width="5%">A</th>
<th width="10%">B</th>
<th width="25%" class="text-left">C</th>
<th width="15%">D</th>
<th width="15%">E</th>
<th width="15%">F</th>
<th width="15%">G</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>##</td>
<td class="text-left">AA</td>
<td>12</td>
<td>12</td>
<td>2</td>
<td>4</td>
</tr>
<tr>
<td>2</td>
<td>##</td>
<td class="text-left">BB</td>
<td>12</td>
<td>11.7</td>
<td>1</td>
<td>2</td>
</tr>
<tr>
<td>3</td>
<td>##</td>
<td class="text-left">CC</td>
<td>12</td>
<td>11.7</td>
<td>1</td>
<td>2</td>
</tr>
<tr>
<td>4</td>
<td>##</td>
<td class="text-left">DD</td>
<td>11.7</td>
<td>10.7</td>
<td>9</td>
<td>3</td>
</tr>
<tr>
<td>5</td>
<td>##</td>
<td class="text-left">EE</td>
<td>12</td>
<td>10.4</td>
<td>3</td>
<td>9</td>
</tr>
<tr>
<td class="text-center br" colspan="7"> Click to view all</td>
</tr>
<tr>
<td>32</td>
<td>##</td>
<td class="text-left">FF</td>
<td>12</td>
<td>12</td>
<td>2</td>
<td>4</td>
</tr>
<tr>
<td>33</td>
<td>##</td>
<td class="text-left">GG</td>
<td>12</td>
<td>11.7</td>
<td>1</td>
<td>2</td>
</tr>
<tr>
<td>34</td>
<td>##</td>
<td class="text-left">HH</td>
<td>12</td>
<td>11.7</td>
<td>1</td>
<td>2</td>
</tr>
<tr>
<td>35</td>
<td>##</td>
<td class="text-left">II</td>
<td>11.7</td>
<td>10.7</td>
<td>9</td>
<td>3</td>
</tr>
<tr>
<td>36</td>
<td>##</td>
<td class="text-left">JJ</td>
<td>12</td>
<td>10.4</td>
<td>3</td>
<td>9</td>
</tr>
</tbody>
</table>
</div>
please find the fiddle just for demo purpose -
http://jsfiddle.net/samirshah1187/Br28J/
Assuming I have understood your question correctly, you want the first and last five rows to always be visible, with the option to toggle the rows inbetween? If so, try this:
Controller:
function MyCtrl($scope) {
// Create Test Array
$scope.myArray = Array.apply(null, {length: 20}).map(Number.call, Number)
$scope.hideRows = true
$scope.toggleHiddenRows = function() {
$scope.hideRows = !$scope.hideRows
}
}
View:
<body ng-controller="MyCtrl">
<table>
<tr ng-repeat="value in myArray" ng-hide="hideRows && $index > 4 && $index < (myArray.length - 5)">
<td>Row: {{value}}</td>
</tr>
</table>
<button ng-click="toggleHiddenRows()">Toggle Hidden Rows</button>
</body>