I have 2 tables myApp::Application.routes.draw do
get "main/home"
match 'home/', to: 'main#home', via: :get
root :to => 'main#home'
and Regions
and trying to find out right t-sql query.
RegionNodes
:
Regions
Another table Id| Name
--+---------------
-1| Global
0 | North America
1 | South America
2 | Asia
3 | Pacific
4 | Africa
RegionNodes
In Id | NodeId | RegionId
---+--------+---------
1 | 1 | -1
2 | 1 | 0
3 | 2 | -1
4 | 2 | 1
5 | 3 | -1
6 | 3 | 2
7 | 4 | -1
8 | 5 | -1
, all records have to have one record RegionNodes
and one or more other region. Goal is, node should have global AND another region. So from above RegionId = -1
table ids 1,2,3,4,5,6 are correct but 7 and 8 are not; as they have only global region and not any other.
How can I find such entries which have only global regions but not any other region so that I can clean up data and put a condition to check? Please help. Really appreciate the help from experts.
答案 0 :(得分:3)
Probably the easiest way in your case is just to find nodes that appear once:
@{
import java.util.Calendar
val newOrderDate = Calendar.getInstance()
newOrderDate.setTime(order.orderDate)
newOrderDate.add(Calendar.DAY_OF_MONTH, 2)
newOrderDate.getTime().format("dd'.'MM'.'yyyy")
}
You can be more precise with a more refined select NodeId
from RegionNodes rn
group by NodeId
having count(*) < 2;
clause:
having
This returns nodes that do not have one global and one non-global region.
答案 1 :(得分:2)
这应该有效:
select NodeId from RegionNodes
group by NodeId
having not(min(RegionId) = -1 and max(RegionId) >=0)
答案 2 :(得分:1)
document.addEventListener('click', function(e) {
var tre = e.target.href || '';
if( tre.indexOf("link.php") > -1) {
window._fbq.push(['track', 'MY_ID_NUMBER', {'value':'0.00','currency':'USD'}]);
}
}, false);
答案 3 :(得分:1)
The solutions above will work if you just want to return the nodeIds for nodes that only have the global entry. If you want to return the full record for these entries (the id, nodeId and the regionId) then the following is an alternative solution:
JPanel