Filter in ERD-Diagram - entity-relationship

could someone help me with this problem.
I have some "filter-options", its RANGE and CODE.
With these filters i have to inner-join the BOOST-Entity on RANGE and CODE to get RESULT1.
Now i have to use RESULT1 and do a second inner join with DATA on the ID to get RESULT2.
I dont know how to draw it right, or can i complete this task with some other notation, like chen?
Here is a picture.
https://imgur.com/pFsFaIr

Related

How to join filtered results to get this?

I'm using this filter functions through out a column:
=FILTER({$A$3:$A, $L$3:$L}, $E$3:$E =F4)
The output is obviously 2 columns and could be 2-4 number of rows:
I want the output data in a single cell like this: 1(24,655)+2(10,000)
If that is impossible than at least this: 1-24,655 / 2-10,000
The closest I managed is just to put the data in single cell by using textjoin: =textjoin("-",1,FILTER(..))
which resulted in: 1-24,655-2-10,000 (I have no clue what further can I do)
Please Help!
try:
=JOIN("+", FILTER({A3:A&"("&L3:L&")"}, E3:E=F4))

Exact match in dget function with an array as the criteria

Example Sheet I'm trying to get an exact match with an array in the criteria section of dget. Maybe there is another way to work around this, but I'm trying to give it a dynamic component in the array.
=dget('Micro Data'!$A$1:J,"PCR Score",{"Micro Type","Stage Type","Tank","ID#";"PCR PAL","Bright",F2,H2})
Sometimes all criteria matches multiple data points except the "Tank". However the tanks won't exactly match. Ex. All the data is the same in two data sets, except the tanks are CT1 and CT18. This then comes up with the #NUM! error. I'm trying to find if there is a way to get an exact match in the array data while still allowing it to reference the cell?
I know there is the option of making it "=XXX" making it a txt string, but this would take away the dynamic function. I would also loose the auto updating aspect when more data is added.
Thanks
Ryan, see my solution using a query, in Retain Log-GK, cell F2. I think it is just as dynamic as the dget, but perhaps not. It will need some error wrapping to avoid errors if no result found.
Formula is basically:
=query('Criteria Source'!A2:J5,
"select J where B = '"&D9&"' and C = '"&D10&"' and E = '"&D11&"' and D ='"& D2 & "' ",0)
I made all of the criteria dynamic, though obviously you can do it whatever way suits you best...
Let me know of any questions. I'll check back later...

hierarchyID GetAncestor as ID

Problem: I need to extrapolate the parentID from the hierarchyID.
Example: My columnID is 8 and my current hierarchyID is /1/2/4/8. When I call columnName.GetAncestor(1), this will give me /1/2/4/. What I need is the ID of 4.
How do I do this? Or are hierarchyIDs only meant to be joined on?
I'm looking into the SqlHierarchyID.Parse() but I'm not understanding how to use it.
In order to get another field value for the GetAncestor(1) hierarchyid you need to do an inner join like this:
SELECT A.hid, A.myid, B.hid, B.myid
FROM dbo.mytable A
INNER JOIN dbo.mytable B ON A.hid.GetAncestor(1) = B.hid
This returns each row with its parent in the same row (will probably miss the root row, though, but if you add a WHERE clause to get the hid you're interested in, then this should suffice).

SQL Query in Rails

I have table with 3 columns : tableno,itmname, itmtype. The itmtype can be red or blue only. This table may have rows like: table01,item1,red ; table01,item2,blue; table02,item1,blue; table02,item4,red; table03,item1,red; table03,item5,red.
Now I need to extract tableno for which all itmtypes is red. So from above rows I need output as table03 as itmtype is red for both items in it. Normally if I put where condition for itmtype as red, it may fetch table01 & table02 as well coz both has one item with itmtype red. But I need only table03 as my output coz all itmtype is red for this table.
I am struggling for quite long time writing different types of queries in rails but none of them is working.
I have written a sql query for that unable to write a similar one in rails.
select tableno,itmstatus,count(itmstatus) from lists l1 group by l1.tableno,itmstatus
having itmstatus = 'red' and count(itmstatus) = (select count(itmstatus) from lists l2 where l1.tableno = l2.tableno group by tableno)
Since I am unable to convert this in rails, couldn't test on rails console to check if it will work. I understand that this may sound a basic question but being new to rails I have only used normal select only. Please advise. Thanks.
if you have correct sql syntax then put it in a string and use the find_by_sql method
like
Model.find_by_sql("your query")
please check the links
http://apidock.com/rails/ActiveRecord/Base/find_by_sql/class
find_by_sql with array format in Rails 3

Informix: UPDATE with SELECT - syntax?

I wanna update my table for all persons whoes activity lasted toooo long. The update should correct one time and for the subsequent rows I need to deal with new result. So thought about something like
UPDATE summary_table st
SET st.screen_on=newScreenOnValue
st.active_screen_on=st.active_screen_on-(st.screen_on-newScreenOnValue) --old-value minus thedifference
FROM (
SUB-SELECT with rowid, newScreenOnValue ... JOIN ... WHERE....
) nv
WHERE (st.rowid=nv.rowid)
I know that I can update the first and the second value directly, by rerunning the same query. But my problem is the costs of the subselect seems quite high and therefore wanna avoid a double-update resp. double-run of the same query.
The above SELECT is just a informal way of writting what I think I would like to get. I know that the st doesn't work, but I left it here for better understanding. When I try the above statement I always get back a SyntaxError at the position the FROM ends.
This can be achieved as follows:
UPDATE summary_table st
SET (st.screen_on, st.active_screen_on) =
((SELECT newScreenOnValue, st.active_screen_on-(st.screen_on-newScreenOnValue)
FROM ...
JOIN...
WHERE..))
[WHERE if any additional condition required];
The above query works perfectly fine on informix tried and tested until you make any errors in the FROM, JOIN, WHERE clauses.
Cheers !
Syntax error because a comma is missing between the first and second columns you're updating.
Never use ROWID's, they're volatile and also not used by default with IDS, unless you specify so.
Why are you using a subquery?

Resources