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
Related
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
This is my practice question. I removed the images and added the table into HTML code format.
This below code is of Un Normalized formed.
<table>
<thead>
<tr>
<th>ENo </th>
<th>BNo </th>
<th>Branch </th>
<th>Name </th>
<th>Designation </th>
<th>Salary </th>
<th>DeptNo </th>
<th>DeptName </th>
<th>FromDate </th>
<th>ToDate </th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>2</td>
<td>Deer Road</td>
<td>John</td>
<td>Manager</td>
<td>30000</td>
<td>1</td>
<td>HR</td>
<td>05-04-2001</td>
<td>31-12-2006</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>Deer Road</td>
<td>John</td>
<td>Manager</td>
<td>30000</td>
<td>2</td>
<td>Finance</td>
<td>01-01-2007</td>
<td>--</td>
</tr>
<tr>
<td>1</td>
<td>3</td>
<td>Argyll street</td>
<td>Ann</td>
<td>Assistant</td>
<td>8000</td>
<td>1</td>
<td>HR</td>
<td>01-09-2005</td>
<td>--</td>
</tr>
<tr>
<td>2</td>
<td>1</td>
<td>Main Road</td>
<td>David</td>
<td>Supervisor</td>
<td>15000</td>
<td>3</td>
<td>IT</td>
<td>01-07-2002</td>
<td>--</td>
</tr>
</tbody>
</table>
I converted UNF to 1NF by simply adding another Employee ID (EId) column because currently columns are not uniquely identifying.
This below code is of 1NF Form:
.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-cly1{text-align:left;vertical-align:middle}
.tg .tg-9qwi{background-color:#fd6864;border-color:inherit;font-weight:bold;text-align:center;vertical-align:middle}
.tg .tg-yla0{font-weight:bold;text-align:left;vertical-align:middle}
.tg .tg-vwbk{background-color:#fd6864;text-align:left;vertical-align:bottom}
<table class="tg">
<thead>
<tr>
<th class="tg-9qwi">Eid</th>
<th class="tg-yla0">ENo </th>
<th class="tg-yla0">BNo </th>
<th class="tg-yla0">Branch </th>
<th class="tg-yla0">Name </th>
<th class="tg-yla0">Designation </th>
<th class="tg-yla0">Salary </th>
<th class="tg-yla0">DeptNo </th>
<th class="tg-yla0">DeptName </th>
<th class="tg-yla0">FromDate </th>
<th class="tg-yla0">ToDate </th>
</tr>
</thead>
<tbody>
<tr>
<td class="tg-vwbk">1</td>
<td class="tg-cly1">1</td>
<td class="tg-cly1">2</td>
<td class="tg-cly1">Deer Road</td>
<td class="tg-cly1">John</td>
<td class="tg-cly1">Manager</td>
<td class="tg-cly1">30,000</td>
<td class="tg-cly1">1</td>
<td class="tg-cly1">HR</td>
<td class="tg-cly1">05-04-2001</td>
<td class="tg-cly1">31-12-2006</td>
</tr>
<tr>
<td class="tg-vwbk">1</td>
<td class="tg-cly1">1</td>
<td class="tg-cly1">2</td>
<td class="tg-cly1">Deer Road</td>
<td class="tg-cly1">John</td>
<td class="tg-cly1">Manager</td>
<td class="tg-cly1">30,000</td>
<td class="tg-cly1">2</td>
<td class="tg-cly1">Finance</td>
<td class="tg-cly1">01-01-2007</td>
<td class="tg-cly1">--</td>
</tr>
<tr>
<td class="tg-vwbk">2</td>
<td class="tg-cly1">1</td>
<td class="tg-cly1">3</td>
<td class="tg-cly1">Argyll street</td>
<td class="tg-cly1">Ann</td>
<td class="tg-cly1">Assistant</td>
<td class="tg-cly1">8,000</td>
<td class="tg-cly1">1</td>
<td class="tg-cly1">HR</td>
<td class="tg-cly1">01-09-2005</td>
<td class="tg-cly1">--</td>
</tr>
<tr>
<td class="tg-vwbk">3</td>
<td class="tg-cly1">2</td>
<td class="tg-cly1">1</td>
<td class="tg-cly1">Main Road</td>
<td class="tg-cly1">David</td>
<td class="tg-cly1">Supervisor</td>
<td class="tg-cly1">15,000</td>
<td class="tg-cly1">3</td>
<td class="tg-cly1">IT</td>
<td class="tg-cly1">01-07-2002</td>
<td class="tg-cly1">--</td>
</tr>
</tbody>
</table>
I converted from 1NF to 2NF by breaking the table into three subtables.
this is 2NF subtables code:
<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-9ger{background-color:#fcff2f;text-align:left;vertical-align:bottom}
.tg .tg-ctz4{background-color:#3166ff;text-align:left;vertical-align:bottom}
.tg .tg-u24d{background-color:#fcff2f;text-align:left;vertical-align:middle}
.tg .tg-za14{border-color:inherit;text-align:left;vertical-align:bottom}
.tg .tg-7zrl{text-align:left;vertical-align:bottom}
.tg .tg-yla0{font-weight:bold;text-align:left;vertical-align:middle}
.tg .tg-16v0{background-color:#fcff2f;font-weight:bold;text-align:left;vertical-align:bottom}
.tg .tg-exyj{background-color:#34ff34;font-weight:bold;text-align:left;vertical-align:bottom}
.tg .tg-4aos{background-color:#34ff34;text-align:left;vertical-align:bottom}
.tg .tg-xtan{background-color:#3166ff;font-weight:bold;text-align:left;vertical-align:bottom}
.tg .tg-gl5e{background-color:#fcff2f;font-weight:bold;text-align:left;vertical-align:middle}
</style>
<table class="tg">
<thead>
<tr>
<th class="tg-za14"></th>
<th class="tg-7zrl"></th>
<th class="tg-7zrl"></th>
<th class="tg-7zrl"></th>
<th class="tg-7zrl"></th>
<th class="tg-7zrl"></th>
<th class="tg-yla0">2NF</th>
<th class="tg-7zrl"></th>
<th class="tg-7zrl"></th>
<th class="tg-7zrl"></th>
<th class="tg-7zrl"></th>
<th class="tg-7zrl"></th>
</tr>
</thead>
<tbody>
<tr>
<td class="tg-9ger"></td>
<td class="tg-9ger"></td>
<td class="tg-16v0">Employee Table</td>
<td class="tg-9ger"></td>
<td class="tg-u24d"></td>
<td class="tg-7zrl"></td>
<td class="tg-7zrl"></td>
<td class="tg-exyj">Branch Table</td>
<td class="tg-4aos"></td>
<td class="tg-7zrl"></td>
<td class="tg-xtan" colspan="2">Department Table</td>
</tr>
<tr>
<td class="tg-9ger"></td>
<td class="tg-9ger"></td>
<td class="tg-9ger"></td>
<td class="tg-9ger"></td>
<td class="tg-u24d"></td>
<td class="tg-7zrl"></td>
<td class="tg-7zrl"></td>
<td class="tg-4aos"></td>
<td class="tg-4aos"></td>
<td class="tg-7zrl"></td>
<td class="tg-ctz4"></td>
<td class="tg-ctz4"></td>
</tr>
<tr>
<td class="tg-16v0">EId</td>
<td class="tg-16v0">ENo</td>
<td class="tg-16v0">Name</td>
<td class="tg-gl5e">Designation</td>
<td class="tg-gl5e">Salary</td>
<td class="tg-7zrl"></td>
<td class="tg-7zrl"></td>
<td class="tg-exyj">BNo</td>
<td class="tg-exyj">Branch</td>
<td class="tg-7zrl"></td>
<td class="tg-xtan">DeptNo</td>
<td class="tg-xtan">DeptName</td>
</tr>
<tr>
<td class="tg-9ger">1</td>
<td class="tg-9ger">1</td>
<td class="tg-9ger">John</td>
<td class="tg-u24d">Manager</td>
<td class="tg-9ger">30,000</td>
<td class="tg-7zrl"></td>
<td class="tg-7zrl"></td>
<td class="tg-4aos">1</td>
<td class="tg-4aos">Main Road</td>
<td class="tg-7zrl"></td>
<td class="tg-ctz4">1</td>
<td class="tg-ctz4">HR</td>
</tr>
<tr>
<td class="tg-9ger">2</td>
<td class="tg-9ger">1</td>
<td class="tg-9ger">Ann</td>
<td class="tg-9ger">Assistant</td>
<td class="tg-9ger">8,000</td>
<td class="tg-7zrl"></td>
<td class="tg-7zrl"></td>
<td class="tg-4aos">2</td>
<td class="tg-4aos">Deer Road</td>
<td class="tg-7zrl"></td>
<td class="tg-ctz4">2</td>
<td class="tg-ctz4">Finance</td>
</tr>
<tr>
<td class="tg-9ger">3</td>
<td class="tg-9ger">2</td>
<td class="tg-9ger">David</td>
<td class="tg-9ger">Supervisor</td>
<td class="tg-9ger">15,000</td>
<td class="tg-7zrl"></td>
<td class="tg-7zrl"></td>
<td class="tg-4aos">3</td>
<td class="tg-4aos">Argyll Street</td>
<td class="tg-7zrl"></td>
<td class="tg-ctz4">3</td>
<td class="tg-ctz4">IT</td>
</tr>
</tbody>
</table>
after that, I stuck on how to normalized this from the date and to date column.
I need suggestions with which table I have to add this from and to date column?
Normalization never introduces new attributes. You introduced Eid.
This is a practice question, not a real-world database design. For example, employees don't have last names in this design. That's not "real world". But it's a defensible simplification for a practice question.
In the context of a practice question, "Eno" suggests that column should be understood as "Employee number". We'd usually consider "Employee number" in a table like this to be unique, but John and Ann have the same Eno. That raised a red flag for you, and that's a good thing. But in this context, I would have questioned the data first (ask your professor), because that looks like a typo to me. In the context of this practice question, you should consider "Name" to be identifying.
Normalization doesn't proceed by "breaking a table into subtables". Simplifying a little, normalization proceeds by decomposing a table into projections of that table, based on functional dependencies.
You don't have enough information to know what to do with the attributes FromDate and ToDate, because you don't know what those column names mean. That suggests that "FromDate" and "ToDate" are bad names for these columns. Use more descriptive names, so people don't have to guess.
"FromDate" and "ToDate" might have to do with
Designation (John was a manager from FromDate until ToDate),
Branch (John was assigned to Branch from FromDate until Todate),
Department (John was assigned to Department from FromDate until Todate),
Salary (John drew Salary from FromDate until ToDate),
and so on.
This is one place functional dependencies show they're essential.
I have thead and tbody in the table.
Thead contains a few s in . Each of it have an id. I need to find the index of td in thead by id and then find by index in tbody.
<table>
<thead>
<tr>
<td data-date="2019-08-05"></td>
<td data-date="2019-08-06"></td> //find index of this element
<td data-date="2019-08-07"></td>
</tr>
</thead>
<tbody>
<tr>
<td>aaa</td>
<td>bbb</td> //find this element by found index
<td>ccc</td>
</tr>
</tbody>
</table>
upd
<table>
<thead>
<tr>
<td data-date="2019-08-05"></td>
<td data-date="2019-08-06"></td>
<td data-date="2019-08-07"></td>
<td data-date="2019-08-08"></td> //find index of this element
<td data-date="2019-08-09"></td>
</tr>
</thead>
<tbody>
<tr>
<td rowspan="2"></td>
<td rowspan="2" class="rrrr">event1 2019-08-06</td>
<td class="rrrr">event1 2019-08-07</td>
<td class="rrrr"event1 2019-08-08</td> //find this element by found index
<td rowspan="2"></td>
</tr>
<tr>
<td class="rrrr">event2 2019-08-07</td>
<td class="rrrr">event2 2019-08-08</td> //find this element by found index
</tr>
</tbody>
</table>
This xpath expression
//tbody//td[count(//thead//td[#data-date='2019-08-06']/preceding-sibling::*)+1]
selects
<td>bbb</td>
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 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.
Selecting records with column value NOT NULL vs one that are NULL
It sounds like a typical SELECT * FROM Table WHERE Column IS NOT NULL...but not quite
Below is a table that represents a portion of data that I need to work with.
<table>
<tr>
<td align="center">Index</td>
<td align="center">A</td>
<td align="center">B</td>
<td align="center">C</td>
</tr>
<tr>
<td align="center">0</td>
<td align="center">NULL</td>
<td align="center">NULL</td>
<td align="center">NULL</td>
</tr>
<tr>
<td align="center">1</td>
<td align="center">NULL</td>
<td align="center">NULL</td>
<td align="center">1</td>
</tr>
<tr>
<td align="center">2</td>
<td align="center">NULL</td>
<td align="center">1</td>
<td align="center">NULL</td>
</tr>
<tr>
<td align="center">3</td>
<td align="center">NULL</td>
<td align="center">1</td>
<td align="center">1</td>
</tr>
<tr>
<td align="center">4</td>
<td align="center">1</td>
<td align="center">NULL</td>
<td align="center">NULL</td>
</tr>
<tr>
<td align="center">5</td>
<td align="center">1</td>
<td align="center">NULL</td>
<td align="center">1</td>
</tr>
<tr>
<td align="center">6</td>
<td align="center">1</td>
<td align="center">1</td>
<td align="center">NULL</td>
</tr>
<tr>
<td align="center">7</td>
<td align="center">1</td>
<td align="center">1</td>
<td align="center">1</td>
</tr>
</table>
Index 0 record represent the default record that everyone would use if there was no override value for A, B, or C
I am always querying with values for A, B & C but if nothing is found I want the NULL record OR NULL value combination.
By the way I am trying to do this SQL-Server 2005.
I have been trying something like
SELECT * FROM Table
WHERE (A = 1 OR A IS NULL) OR (B = 1 OR B IS NULL) OR (C = 1 )
The actual query is a cross join of 4 tables...so the table of values represent the final part of what I am trying to solve.
Also Index 0 represent the result if nothing matches...but I could have more that one record return and process further in php
Assuming your where clause has the intent to always return 1 or 0 records...
simply union the index 0 always and select the top 1 descending. This will always return 1 record and it will always be the 1 matching criteria OR the 0, unless your where clause returns more than 1 record, in which case this will return the highest index matched.
SELECT Top 1 *
FROM (
SELECT *
FROM TABLE
WHERE A=A AND B=B AND C=C
UNION ALL
SELECT * FROM TABLE WHERE INDEX=0) B
ORDER BY index desc;