Thank You visakh16 --- The following section of my querie works but doesn't give the exact information that I need. This is what is giving me:
NetworkId Full Name Sec Class Desc Sec Type Desc SecValue
tte Test Scenario Accounting Budget Center 142- ?
SELECT a.Network_ID, b.Last_Name + ', ' + b.Preferred_FirstName AS full_name, c.Security_Class_Description,
d.Security_Type_Description, a.Security_Value
FROM Company_Hierarchy_Security a
JOIN V_Entity_Employee_Active b on a.Network_ID= b.Network_ID
JOIN Company_Security_Class c on a.Security_Class_Code=c.Security_Class_Code
JOIN Company_Security_Type d on a.Security_Type = d.Security_Type
------------------
inner join (select e.Budget_Center_ID + ' - ' + e.Budget_Center_Description As Budget_Center_Description,
f.Company_Name, g.Enterprise_Description, h.Business_Segment_Description,
i.Team_Description
from Company_Hierarchy_Security a.
Inner JOIN Budget_Center e on a.Security_Value = e.Budget_Center_ID
Inner JOIN Company f on a.Security_Value = f.Company_ID
Inner JOIN Enterprise g ON a.Security_Value = Cast(g.Enterprise_Number As Varchar(5))
Inner JOIN Business_Segment h on a.Security_Value = h.Business_Segment_ID
Inner JOIN Team i on a.Security_Value = i.Team_ID
SELECT a.Network_ID, b.Last_Name + ', ' + b.Preferred_FirstName AS full_name, c.Security_Class_Description, d.Security_Type_Description, a.Security_Value FROM Company_Hierarchy_Security a JOIN V_Entity_Employee_Active b on a.Network_ID= b.Network_ID JOIN Company_Security_Class c on a.Security_Class_Code=c.Security_Class_Code JOIN Company_Security_Type d on a.Security_Type = d.Security_Type inner join (select e.Budget_Center_ID + ' - ' + e.Budget_Center_Description As Budget_Center_Description, f.Company_Name, g.Enterprise_Description, h.Business_Segment_Description, i.Team_Description from Company_Hierarchy_Security a. Inner JOIN Budget_Center e on a.Security_Value = e.Budget_Center_ID Inner JOIN Company f on a.Security_Value = f.Company_ID Inner JOIN Enterprise g ON a.Security_Value = Cast(g.Enterprise_Number As Varchar(5)) Inner JOIN Business_Segment h on a.Security_Value = h.Business_Segment_ID Inner JOIN Team i on a.Security_Value = i.Team_ID
Ok. I have the Security Value located in Company_Hierarchy_Security table. All those values are divided into 5 other tables that I need to join together. I found all of them separate but I have not been able to figue it out how to put it together with the rest of the querie.
I got assignment, how to make it appear in the right order .
/* DROP TABLE EMP SELECT * INTO Emp FROM ( SELECT 'A' EmpID, NULL ManID, 'Name' EmpName UNION ALL SELECT 'MAC' EmpID, 'A' ManID, 'Name__' EmpName UNION ALL SELECT '1ABA' EmpID, 'MAC' ManID, 'Name____' EmpName UNION ALL SELECT 'ABB' EmpID, '1ABA' ManID, 'Name______' EmpName UNION ALL SELECT 'XB' EmpID, 'A' ManID, 'Name__' EmpName UNION ALL SELECT 'BAC' EmpID, 'XB' ManID, 'Name____' EmpName ) b */
I would like to know how to create a single level hierachy structure in SQL. Example, I have a single parent record in table A that may later on spawn one or child record in table B that relates back to the parent. It only needs a single level. that means, one to many.
table1 has 3 fields a , b and c. field "a" is a primary key. table2 has 2 fields x and y. Fields x and y are nothing but the value of "a". Also, y is the child of x. Therefore, x and y can never have same value. It means value of "a" either be child or parent. But there is possibility that parent has no child.
Now, i wanted to write Select/Insert query for parent, b , c and child.
Hi, I'm having a major brain-failure moment here. Using T-SQL I want to be able to get all of the leaf nodes (e.g. nodes at the furthest end of a tree from the root) in a hierarchical relationship where the table structure is such NodeID|ParentID|NodeName. Basically if I had the following tree structure: Root Child1 Grandchild1 Child2 Grandchild2
I want to get all of the Grandchild nodes. Number of levels will vary and I haven't got any kind of HasChilds column. I know this is possible because I remember having done it on a course years ago but I can't for the life of me figure it out on this sunny Friday afternoon. I know it's going to involve either recursion, a while loop or cursors but my mind is currently jelly. Can anyone help?
hi. I am working on Multiline Marketing Project.I have to calculate all the childens and display the whole tree..I have save records in tree format...But not able to calculate the all childrens. SELECT count(*) FROM dfTree WHERE id in (SELECT id FROM dfTree WHERE lineage like '16%') This query works properly.Problem is that it is not working in the project because in the like I have to pass a variable. SELECT count(*) FROM dfTree WHERE id in (SELECT id FROM dfTree WHERE lineage like '@idl%') Please Suggest me...
HI, I am working on a Family tree portal which need tree functionality to display family members in tree structure. on click on any node the adding option should be displayed for this i need a table and procedure to complete family tree Thanks @mbi
Consider the following SQL query: SELECT ENAME,SAL FROM EMP,ASG,PAY,PROJ WHERE EMP.ENO=ASG.ENO AND PAY.TITLE=EMP.TITLE AND ASG.PNO=PROJ.PNO AND ASG.DUR=48 AND BUDGET>200000 Give the possible operator trees:right-deep,left-deep and bush Tank you very much!
i'm writing a app in c# and have to store Trees in a Database.
I'm working with Datasets for the exchange between the DB and the App.
The trees have the same options like the windows folders. If u delete a node, all subnodes should be deleted too.
But something a Foreign Key from ParentID references (Id) with the delete-Rule on cascade seems not to be possible, because of multiple cascade Paths or cycles. Do i have to add some xtra constarins:
Not Possible:
create Table tree ( Id varchar Not null, ParentId varchar Not null, Constraint pk1 Primary Key (Id), Constraint fk1 Foreign Key (ParentId) references tree(Id) On Update Cascade On delete CAscade )
Do i have to write triggers, which delete The subnodes too and set the Update-/deleterulr on NO Action
Does anyone know any good links for SQL tree structures and example queries and stuff... I cant really find anything part from the standard example of emplyee, boss, salary which explains how to create the tree table...(dun dis bit) I did notice a book but I live in a little village so cant go get it till wekend?
I'm desperate, reli need to work out how too do this.....
Any recomendations on how to store organization trees on a database withlots of paths and branches? Any white papers out there that explain this?Thanks
Hello,I have a "tree" table:Id - primary keyParrentId - (foreign key) related to IdTitle.....when I delete some record I want to delete it with all childs (cascadedeleting). I can't set cascade deleting on the same table :(. Is thereany easy way in the MSSQL 2005 to do this ? There is one idea - usingcursors + recursive functions but I think this solution is not easyand elegant.Thakns for any help and sugestions.Regards.Andy
I wanted to use the Decision Tree to show a result..... after i configure the Mining Structures..... and set all the input.... my decision tree shows only until level 2..... i have 3 input and one PredictOnly column.....where is the other input?
Say.... i have House Owner, Marital Status, Num Cars Owned and Number Of Children(PredictOnly)
my Tree only shows All ---- > Marital Status when i input all 3 together...... the other 2 doesn't seems to show.
wat should i do?? my database in SQL Server and the other keys are all correct and deploying finely.....why is this happening.....?
i'm a newbie in this software.......so any pro here can plz help me if there's actually something that i might have missed out along the way.......
i have tried 3 different solutions all coming to a crash at some point, if ANYONE can help me out i would appreciate it, i know the logic will be recursive, i just dont know how to implement
Hi..I have a table register..in this fields are username,parent id,downline ; I have to determine all the child of a particular parent. suppose table is like this. username parentid downline B A left C A right D B left E B right.... I have to also determine the level in the tree....please help...
I just started having this problem. When I log into SQL2000 enterprise manager and click on my database, the main directory tree shows up. When I click on the Database tree to display all of the different databases on the SQL server, the text 'No Items' shows up. I can not get to any databases, but I am connected to the SQL server. Does anyone have a solution for this problem?????
I have tried re-inatalling and all of the service packs.
Okie, this one has me a little stumped so bear with me an I will explain as best I can....
I have a family tree database...
The two key tables (for this problem) are Person and Child. The person table is your generic person details table and contains, PersonId, PersonFirstName, PersonLastName, PersonDOB etc. The Child table is a linking table that links a PersonId to a ChildPersonId (so both Id's are valid Id's in the person table).
Now what I want to try and achieve is a breakdown of the different branchs of the family tree. A branch is an independant, unattached section of the tree (if that makes sense). It's a grouping of people we know are related but we can't determine how they are related to another group of people in the tree.
If you look at this http://gw.geneanet.org/index.php3?b=bengos&lang=en;m=N;v=van+halewyn you will get an idea of what I mean.
I'm not sure if this is something that can be don't with a query at all the be honest... I suspect that I will have to wrap some other code around it, but I'm really not sure on what approach I should be using. Any help people could offer would be great.
One of the users on another web site posted a question about how to associate users in a tree-like organization. That web site isn't well suited to posting code or ongoing discussions about code, so I'm going to post the example here. Feel free to discuss as you see fit.DROP TABLE LI_UserLinks GO DROP TABLE LI_Users GO DECLARE @d1DATETIME , @d2DATETIME , @d3DATETIME , @d4DATETIME , @d5DATETIME , @d6DATETIME , @d7DATETIME , @d8DATETIME
ALTER TABLE LI_Userlinks ADD CONSTRAINT XCK01LI_UserLinks CHECK (uid_from != uid_to)
SELECT @d3 = GetDate()
INSERT INTO LI_Users ( uid) SELECT n0 + 10 * n1 + 100 * n2 + 1000 * n3 + 10000 * n4 + 100000 * n5 FROM (SELECT 0 AS n0 UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 UNION SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION SELECT 9) AS z0 CROSS JOIN (SELECT 0 AS n1 UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 UNION SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION SELECT 9) AS z1 CROSS JOIN (SELECT 0 AS n2 UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 UNION SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION SELECT 9) AS z2 CROSS JOIN (SELECT 0 AS n3 UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 UNION SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION SELECT 9) AS z3 CROSS JOIN (SELECT 0 AS n4 UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 UNION SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION SELECT 9) AS z4 CROSS JOIN (SELECT 0 AS n5 UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 UNION SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION SELECT 9) AS z5
SELECT @d4 = GetDate()
INSERT INTO LI_UserLinks ( uid_from, uid_to) SELECT uid, 100 * uid + n0 + 10 * n1 FROM LI_Users CROSS JOIN (SELECT 0 AS n0 UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 UNION SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION SELECT 9) AS z0 CROSS JOIN (SELECT 0 AS n1 UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 UNION SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION SELECT 9) AS z1 WHERE LI_Users.uid BETWEEN 0 AND 99 AND uid != 100 * uid + n0 + 10 * n1
SELECT @d5 = GetDate()
INSERT INTO LI_UserLinks ( uid_from, uid_to) SELECT uid, 100 * uid + n0 + 10 * n1 FROM LI_Users CROSS JOIN (SELECT 0 AS n0 UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 UNION SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION SELECT 9) AS z0 CROSS JOIN (SELECT 0 AS n1 UNION SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 UNION SELECT 6 UNION SELECT 7 UNION SELECT 8 UNION SELECT 9) AS z1 WHERE LI_Users.uid BETWEEN 100 AND 9999
SELECT @d6 = GetDate()
SELECT u.uid, r1.uid_to, r2.uid_to FROM LI_Users AS u INNER JOIN LI_UserLinks AS r1 ON (r1.uid_from = u.uid) INNER JOIN LI_UserLinks AS r2 ON (r2.uid_from = r1.uid_to) WHERE 1 = u.uid
SELECT @d7 = GetDate()
SELECT Count(DISTINCT u.uid), Count(DISTINCT r1.uid_to), Count(distinct r2.uid_to) FROM LI_Users AS u INNER JOIN LI_UserLinks AS r1 ON (r1.uid_from = u.uid) INNER JOIN LI_UserLinks AS r2 ON (r2.uid_from = r1.uid_to)
hello i have implemented joe celko's model to store heirarchy and itworks well and nicei have a question about SQLthis is the actual tablemember side left right------------------------------------------nancy L 1 36andrew L 4 21steven R 5 12ina L 6 7david R 10 11margaret L 13 20ann R 14 15laura L 18 19janet R 24 35michael L 25 30dan R 26 27ron L 28 29robert R 33 34the Side column is to tell its left, or right. this is a binaryheirarcy.i have this problem i have to solve, im still banging my head. Ifgiven the member'Nancy' , i need to find left-most(Laura) and right-most(Robert)'Janet' = left most is ron, right most is robert'Andrew = left most is laura, right most is DavidHope u get my plan. could u help me with the sql ?
I am going through the Data Mining Web Control sample and have that working beautifully. I now want to add in some more functionality by allowing the end user to select the: database, model and tree to view in the web viewer (similar to the parameters in SSRS). I am trying to figure out a way to get all this data programatically. So far this is what I have:
Code Snippet
For Each newDB As Microsoft.AnalysisServices.Database In myserver.Databases
dbName = newDB.Name.ToString
myLog.AppendText("DATABASE NAME - " + dbName + vbCrLf)
For Each newStructure As Microsoft.AnalysisServices.MiningStructure In newDB.MiningStructures
For Each newModel As Microsoft.AnalysisServices.MiningModel In newStructure.MiningModels
modelName = newModel.ToString
modelAlgorithm = newModel.Algorithm.ToString
myLog.AppendText(" MODEL NAME -" + modelName + " " + modelAlgorithm + vbCrLf)
This works beautifully but I am having a problem getting the tree name which i believe its called the "attribute_name".
I can run the following SQL against Analysis Services and get the attribute name but I would like to get all this programatically and insert into a table.
Code Snippet
SELECT attribute_name
FROM [model].content
WHERE node_type=2
I plan to run this daily and update a table. This will ultimately let me pull the structure into my data mining viewer page. This way, I will only have to have one viewer page for all models, instead of a new page for each.
Can anyone please help me? I need to create a tree structure of my company's database server. I need to include all the tables and their description in a tree structure. The output can be in any format. Is there some tool in the MSSql that will do this for me, so I don't have to write it out manualy?? Thank you very much for any ideas!! M.
Can we represent the Decision Tree in a programatically way in an .NET application? I understand that the outcome of a Decision Tree model can be integrated into an .NET application but not sure if we can also visualize it. Does MS SQL Server support any API to render such a tree?
I am in starting phase of a data conversion project. As my ETL target, I have to produce around 70 flat files. I am creating one package for each target file. Some target files may be a result of 2-3 packages. I have some common packages that get called from many other packages.
Before my solution tree grows into unmanageable state, I would like packages to get organized based on their target and purpose of the package. The ideal solution to this problem would be to organize packages in a folder structure but I couldn€™t see any option to create folders in a solution. I also noticed that we can€™t easily put package files next to each other even after renaming packages.
I was wondering is there a better or any way to organize packages in solution tree?
I have got a lot of results like the following two nodes:
All Existing Cases: 1035298 Missing Cases: 1604 Y = 3,214,966,177,062,520,000,000.000
a >= -0.9822378254 and < -0.7867621803 Existing Cases: 45291 Missing Cases: 17 Y = 9,491,528,329,086,450,000,000.000
Every node of the tree is as odd as this. I checked the training data and found there are 5 bad points with extraordinarily high values of Y. There are over a million points, how can these five points screw up the entire analysis.
I do have good results for other predicted parameters even though they also bad points.
My question is how to make a tree from the case above I mean what method we should use to split the tree. (Mannually counting) I hope anyone could help me by explaining i details.Because i want to make some analysis how microsoft decision tree works exactly.So Please explain me the process to build the tree completely with the method.
I have successfully created and processed a mining structure (decision tree). However, when I try to generate the tree graph, I am getting the following error:
TITLE: Microsoft Visual Studio ------------------------------ The tree graph cannot be created because of the following error: 'Object reference not set to an instance of an object.'. For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft%u00ae+Visual+Studio%u00ae+2005&ProdVer=8.0.50727.762&EvtSrc=Microsoft.AnalysisServices.Viewers.SR&EvtID=ErrorCreateGraphFailed&LinkId=20476 ------------------------------ ADDITIONAL INFORMATION: Object reference not set to an instance of an object. (Microsoft.AnalysisServices.Viewers) ------------------------------ BUTTONS: OK ------------------------------
...with the following technical details
=================================== The tree graph cannot be created because of the following error: 'Object reference not set to an instance of an object.'. (Microsoft Visual Studio) ------------------------------ For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft%u00ae+Visual+Studio%u00ae+2005&ProdVer=8.0.50727.762&EvtSrc=Microsoft.AnalysisServices.Viewers.SR&EvtID=ErrorCreateGraphFailed&LinkId=20476 =================================== Object reference not set to an instance of an object. (Microsoft.AnalysisServices.Viewers) ------------------------------ Program Location: at Microsoft.AnalysisServices.Viewers.TreeViewerBase.GetTooltipText(TreeGraphNode treeNode) at Microsoft.AnalysisServices.Viewers.TreeViewerBase.predictionTreeComboBox_SelectedIndexAction() Has anyone encountered this same error?