ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

Main Area and Open Discussion > General Software Discussion

SQL query newbie: Help me work through my first project?

(1/2) > >>

superboyac:
Hi everyone, I've gotten my hands into programming now after not doing anything like this for maybe 10 years now.  I'm working with an Oracle database and I'm just starting to learn how to run SQL queries.  I've gotten the basics so far of the select, where functions.  But I'm trying to do a little more fancy things, and it's becoming difficult.  So I wouldn't mind getting coached throughout this thread.  Yeah?

First challenge:
I've been able to write a simple query using and/or statements.  Now, I want to group everything in a particular way to reflect the hierarchy that the database is representing.  So I need to somehow figure out how to group things according to the proper parents/children.  What I'm doing now is trying to figure out which columns control the hierarchy, because it's not clear, and I can't ask anyone here.

mouser:
I think you might need to be a little more specific and maybe give some example data.

And furthermore, when you talk about grouping and hierarchy it sounds like you are talking about how to organize the data after it comes back from sql in whatever other language you are using -- since sql really will only ever return rows of flat data.  Or maybe you're talking about how to pull data from multiple tables based on what they call "foreign keys", where you are combining rows from different tables based on matching column values.  Either way, i think you'll need to be more specific.

superboyac:
Sure, I just don't know how confidential everything is.  here's an example:
and DESCRIPTION like '%{%}%'
--- End quote ---
I'm trying to add a way for the query to return matches that only contain the bracket symbols "{" and "}" in the description column.  I have entries that have a code inside brackets like "{something here} some text", and I only want those returned.  So the brackets are the distinguishing feature.  But I just ran the query, and that and statement above didn't do anything.

superboyac:
Ok, I got the above question resolved.  No questions for now.

superboyac:
I'm having a real hard time trying to get a query to return some kind of outline numbering.  So, I've been able to arrange my query results in the proper hierarchical order using the Oracle hierarchical functions like:
Start with
connect by prior

So that's good.  Now I need to add a column showing the outline numbering, such as:
1
1.1
1.2
1.2.1
1.2.2
etc.

How do i do that?  I've tried using this:
SYS_CONNECT_BY_PATH

but the hard part is trying to get it to COUNT the items as it goes through the hierarchy.  The closest I've come to using the connect by path command above is to show the path to of the row in the hierarchy.  So I can get it to show something like:
Parent/Child1/Child2
But I'd like it to do the "1.2.1" kind of numbering instead.  Any thoughts?  I'm missing a way to make it count stuff.

Navigation

[0] Message Index

[#] Next page

Go to full version