Can this be done using a single sql......

Hi,
I have a problem to solve an was just wondering if it was possible to do it using a single sql. It is not imperative that I use a single sql but would like to know if it were possible and if so how, else I would appreciate if I was guided in the general direction where I may be able to find a solution....
1) Esstentially in this example an employee can have 3 types of managers 'A' 'B' or 'C'.
2) the emplyee must have 1 and only 1 manager of type 'A' (it is imperative that an emp have a manager of type A)
3) the employee can have multiple managers of Type B and C but it is possible that the emp does not have any manager of type B and C
We need a report which compares all the type B managers of an employee to the type A manager of the same employee and if any one of the Type B manager is same as the type A manager then the report indicates 'Equal' else the report indicates 'Not Equal'. if there is no type B manager for the employee then the report should show is as 'Not Equal'.
The same comparsion need to be done between type C and type A managers for the employee...
here are the scripts you would require to create a dummy table with data
?SCRIPTS START?
create table emp (empid number(3), mgrid number(3), mgr_type varchar2(1))
insert into emp values (1,3,'A')
insert into emp values (1,10,'B')
insert into emp values (1,14,'C')
insert into emp values (2,15,'A')
insert into emp values (3,10,'A')
insert into emp values (3,10,'B')
insert into emp values (3,10,'C')
insert into emp values (4,12,'A')
insert into emp values (5,2,'A')
insert into emp values (5,2,'B')
insert into emp values (5,3,'B')
insert into emp values (6,1,'A')
insert into emp values (6,5,'C')
select * from emp
?SCRIPTS-END?
EMPID> MGRID> M
1> 3> A
1 > 10 > B
1 > 14 > C
2 > 15 > A
3 > 10 > A
3 > 10 >B
3 > 10> C
4 >12 > A
4 > 12 > C
5 > 2 > A
5 >2 > B
5 > 3> B
6 > 1 > A
6 > 5 > C
6 > 7 > C
Expected Report
emp_id>     mgr_type_A>     mgr_type_B>     mgr_type_C
1>>>     3>>>          Not Equal>>>     Not Equal
2>>>     15>>>          Not Equal>>>     Not Equal
3>>>     10>>>          Equal>>>          Equal
4>>>     12>>>          Not Equal>>>     Equal
5>>>     2>>>          Equal>>>          Not Equal
6>>>     1>>>          Not Equal>>>     Not Equal
at the end of the day the report is to be exported as an xls. I would be using java to connect to the DB and create the xls. Obv I could run a simple sql and do a lot of comparision in java and get the desired report... What I am looking for is
- Is it possible using a single sql.
- if not.. is it better to use a pl/sql procedure or do it using java code.
the table has abt 100,000 records .... performance is not really a factor right now...
I just have no idea where to look.. I thought of pivot tables but could not find a solution... thought of decode as well... but again to no avail... (i am not oracle expert by any means....)
Appreciate any help I can get...
Thanks...
PS: Have used > to seperate the data.. since the preview of the post was truncating all spaces between the columns and was making it difficult to differetiate the data....
ooooppppsss....just realised i should have put this in the PL/SQL forum.. dont' seem to find an option to delete the post.. so if someone can move it to the other forum... it would be great....
Message was edited by:
user520267

Well, there are no moderators here, so you are going to have to get your answer here :-). Most of us that hang out in PL/SQL are here too.
Assuming that 4>>> 12>>> Not Equal>>> Equal is a typo because there is only one record for empid 4, this works. There may be more efficient ways but ...
SQL> SELECT a.empid, a.mgrid,
  2         NVL((SELECT 'EQUAL' FROM emp b
  3             WHERE b.empid = a.empid and
  4                   b.mgrid = a.mgrid and
  5                   b.mgr_type = 'B'), 'NOT EQUAL') bmgr,
  6         NVL((SELECT 'EQUAL' FROM emp c
  7             WHERE c.empid = a.empid and
  8                   c.mgrid = a.mgrid and
  9                   c.mgr_type = 'C'), 'NOT EQUAL') cmgr
10  FROM emp a
11  WHERE mgr_type = 'A';
     EMPID      MGRID BMGR      CMGR
         1          3 NOT EQUAL NOT EQUAL
         2         15 NOT EQUAL NOT EQUAL
         3         10 EQUAL     EQUAL
         4         12 NOT EQUAL NOT EQUAL
         5          2 EQUAL     NOT EQUAL
         6          1 NOT EQUAL NOT EQUALYou can format your code and data, as I did here, by using [ pre ] and [ /pre ] without the spaces around the text you want preserved. [ code ] and [ /code ] works too.
HTH
John

Similar Messages

  • Can a OLAP Cube be Processed in to RAM , Can this be done using Traditional BI ? , If we can place the entire SSAS Cube in RAM for better performance , how can it be done?

    I'm trying to increase the performance of my OLAP Cube and i thought placing the CUbe entirely in RAM can solve this problem. can anyone please answer me , if this can be done using Traditional BI i.e SSAS and how?

    Hi Nagarjuna:
    I do not believe you can load the entire cube into RAM and even if you were able to do so, I don't think you'll be able to solve you performance issues.
    Here is a thread with the same discussion and it has some good links that you can visit to learn more about where the performance issues are emanating from  -
    How to cache all SSAS 2008 cube processed data into RAM
    Also, please tale a look at the followoing guide - Analysis Services Performance
    Guide
    Hope this helps.
    Faisal Muhammed My Blog

  • Can this be done using WLS 8.1 LDAP?

    I am trying to configure WLS 8.1 to use LDAP for authentication/authorization.
    I have the basics working so now I am trying to move to the next hurdle.
    We are building a single webapp that will serve several different companies. The
    main difference will be that the look and feel will be branded for each company
    so when a user logs in to the app via a URL such as foo.domain.com they see the
    "foo" branding and using bar.domain.com will see the "bar" branding. Simple so
    far. The real problem is that we will be adding new companies over time and we
    need to allow two users from two different companies to have the same userid.
    How can I setup LDAP in WLS 8.1 so I can use a different "User Base DN" depending
    on the company the user appears to be coming from? I need this for both authentication
    and authorization.
    - Maybe a custom LDAP realm? Where to begin?
    - How about the "User From Name Filter" field in the console? It seems to take
    a %u variable for the username. Are there any other variables I can use?
    - Do I create a different authenticator for each company? If so, how do I resolve
    one authenticator saying username/password is valid and other says it isn't? Then
    how do I use the correct authorizer for that user?
    I have to imagine that others have had this same issue. Any other ideas?
    Thanks,
    Rick

    "Rick Maddy" <[email protected]> wrote in message
    news:3ee9eccc$[email protected]..
    >
    I am trying to configure WLS 8.1 to use LDAP forauthentication/authorization.
    I have the basics working so now I am trying to move to the next hurdle.
    We are building a single webapp that will serve several differentcompanies. The
    main difference will be that the look and feel will be branded for eachcompany
    so when a user logs in to the app via a URL such as foo.domain.com theysee the
    "foo" branding and using bar.domain.com will see the "bar" branding.Simple so
    far. The real problem is that we will be adding new companies over timeand we
    need to allow two users from two different companies to have the sameuserid.
    >
    How can I setup LDAP in WLS 8.1 so I can use a different "User Base DN"depending
    on the company the user appears to be coming from? I need this for bothauthentication
    and authorization.
    It sounds like you need multiple realm support in additional to virtual host
    support. WLS
    currently only supports one realm activate at a time.
    - Maybe a custom LDAP realm? Where to begin?You might be able to do this with a custom provider, but I am not sure if
    you can
    get at the original URL in the login module.
    - How about the "User From Name Filter" field in the console? It seems totake
    a %u variable for the username. Are there any other variables I can use?You can use %u for username, %g for group, but I don't think they are going
    to help
    you.
    - Do I create a different authenticator for each company? If so, how do Iresolve
    one authenticator saying username/password is valid and other says itisn't? Then
    how do I use the correct authorizer for that user?You can use the control flags to specify the behavior of the login modules.
    But unless
    your usernames are scoped, then it could succeed in one provider when you
    really
    want it to go to the other provider.

  • Can this be done? Emailing a completed form without emailing.

    When using a standard html form, a user can fill in the required fields, press post, and abracadabra, the results of the form are emailed to the specified account and the user is redirected to a page that says your form has been submitted.
    Can this be done using a .pdf? The email button is simply retarded. Why do users have to go through the hassle of having their email client opened just to submit the form they just completed? There probably isn't any other way, but would be nice if there was.
    Is it possible to create a submit button that will automatically email the completed .pdf form to a pre-specified email address and then redirect the user to a "thank you" page? I don't want to annoy my customers by forcing them to email me the form. I just want it sent when they click "submit."
    Is this even possible? If so, is it relatively easy?
    Any help is greatly appreciated!

    >Can this be done using a .pdf?
    Sure. The principle is exactly the same: you submit data to a script
    which runs on a web server. You are limited only by what the
    programmer has made the script do. Don't be under any impression that
    it is "magic": if you have a web form which submits and then you get
    an e-mail it's because there is a script on a web server that a web
    programmer wrote to make it happen.
    > The email button is simply retarded.
    I prefer to think of it as a handy tool for testing, but nothing
    anyone would use for the real solution.
    >Why do users have to go through the hassle of having their email client ...
    They don't. Did you know that you can "submit" an HTML form to e-mail?
    But nobody does, because it just isn't a good way of working. Everyone
    expects an HTML form to submit to a web script, but for some reason
    hopes they can use direct e-mail of PDF forms.
    Aandi Inston

  • Can this be done with css rollovers?

    Hi,
       I'm using Dreamweaver CS4 on a Windows PC. I understand the basics of css rollovers where you change the background image position up or down but the text used will still end up being a common font that will suit every pc. What I'd like to do is use an uncommon font in my navigation bar. I made an image in photoshop that had two versions of a word like home for example one on top of the other like you would for a css rollover but once I created a link I had the link color border around the image, so it didn't work. Here is a link to a website that is similar to what I'm trying to do http://www.inksmithtattoo.com/. Look at the navigation, can this be done using css rollovers? If not how do you think it was done? Is there a way to use uncommon fonts in a navigation bar? I even did some research on using Dreamweavers hotspot function but found that there were issues in using it for navigation. I'm getting pretty familar with Dreamweaver but I'm not that good at coding so if anyone does have any ideas please include some keywords that I can google and read more about what your trying to say, links to the info would be even better but I realize that if your as busy as I am you can't take that kind of time.
    Any ideas or help will be greatly appreciated.
    Thank you to all,  dluthier

    That site is using images only. It is not a text based link:
    here is the css they are using:
    #navAbout a {
    -moz-background-clip:border;
    -moz-background-inline-policy:continuous;
    -moz-background-origin:padding;
    background:transparent url(../_img/navAbout-Home.gif) no-repeat scroll 0 0;
    left:473px;
    top:318px;
    As you can see it is an image only. See the attachment with this post. Also since it is a background image it won't show up if you right click on the so seemed text
    Please install firebug or webdeveloper plugin if on Firefox and you will be able to inspect the elements and know what exactly they are.
    Hope it helps
    Regards,
    Vinay

  • Can this be done with Spry?

    I've got a page that has some menu items displayed in a Flash
    movie. (See this page
    http://www.lunchboxes.ae/offices/samplemenu.php
    for the example).
    Can this be done using a Spry dataset that can be changed
    using Contribute ultimately rather than editing the Flash movie
    every time?

    Hello,
    You should try to look deep in to the source of this:
    Original
    Photo Gallery from the Demos
    Ther is a slide show option. you can put this technique in to
    a table in many times and it will look like what you need.

  • I am trying to extend my airport extreme signal to another airport extreme can this be done? I have tried several time using the automated set up but it keeps failing... What am I doing wrong?

    I am trying to extend my airport extreme signal to another airport extreme can this be done? I have tried several time using the automated set up but it keeps failing... I have selected every possible security/password encryption level... What am I doing wrong? If it os possible where can I find step by step instructions? Please & Thank you!

    The challenge with the older round AirPort Extremes are that they are "g" wireless devices.
    When you configure them for WDS, the speed on the wireless network is cut in half...and probably will not have the bandwidth required to stream video reliably from either AirPort Extreme since both are affected by the WDS setup.
    There is not an "automated" setup for WDS. You have to do this manually on both AirPort Extremes. Unfortunately, it is not an easy configuration and it's easy to make a mistake and hard to recover without starting all over again.
    Apple's instructions for WDS are here if you want to give it a try.
    http://support.apple.com/kb/HT4262
    It is possible that it might work. Keep us posted on your progress
    Adding a single AirPort Express will unfortunately not help. You have to have "n" wireless devices at all router points.

  • I'm trying to crop individual frames. Can this be done without the crop being applied to the entire clip? Using imovie 11

    I'm trying to crop individual frames. Can this be done without the crop being applied to the entire clip? Using imovie 11

    use the cmd-B(lade) command to split your single clip into individual ones

  • I want to Connect my Mac Mini as a Slave to a Mac pro Server while at the same time using the Mac mini's thunderbolt ports peripherals ( ie monitor, Sound Card, Hard drives) Creating a poor man's new mac Pro. Can this be Done?

    I want to Connect my Mac Mini as a Slave to a Mac pro Server while at the same time using the Mac mini's thunderbolt ports peripherals ( ie monitor, Sound Card, Hard drives) Creating a poor man's new mac Pro. Can this be Done?

    Well, I really would love the new unreleased mac pro however , I'm not sure of the expected cost , Everyone speculates from $3,000 to $8,000, in which I may have to wait a while to purchase.
    To the point .... I want fully functional thunderbolt ports to be on the current mac pro's .... wonder if anyone had workarounds yet?...  or could I chain the the current mac pro to a mac mini to make that happen?

  • I want to shoot a movie on my iPhone and edit it on my iPad using the iMovie app. How can this be done via iTunes on my computer?

    I want to shoot a movie on my iPhone and edit it on my iPad using the iMovie app. How can this be done via iTunes on my computer?

    You can't drag video into the filesharing pane of iTunes, you can only transfer projects.
    Videos need to come in via the photos tab of iTunes.
    The easiest way to get videos from the iPhone to the iPad is via the project export import.
    Projects can be exported from the iPhone, then imported to the iPad like this:
    iPhone Send a project or trailer to iTunes
    If the marquee screen isn’t showing, tap the My Projects button .
    Scroll to center the project or trailer you want to share.
    Tap the Share button at the bottom of the screen, and then tap iTunes; tap OK when iMovie indicates that export is complete.
    Connect your device to your computer, and then open iTunes on your computer.After a moment, your device appears in iTunes, below Devices on the left.
    Select the device, and then click Apps at the top of the iTunes window.
    Select iMovie in the Apps list below File Sharing. (You may need to scroll to see it.)
    In the iMovie Documents pane, select the file you just shared, and then click the “Save to” button; save the file to your computer in a place where you can find it easily.You can also save the file by dragging it to the desired location on your computer.
    Disconnect the device from your computer.
    iPad Import a project or trailer from iTunes
    Connect your device to your computer, and open iTunes on your computer.After a moment, your device appears in iTunes, below Devices on the left.
    Select the device, and click Apps at the top of the iTunes window.
    Select iMovie in the Apps list below File Sharing. (You may need to scroll to see it.)
    Click Add below the iMovie Documents pane; in the window that appears, navigate to the file you want to add.
    Select the file, and then click Open to copy the file to your device.The file appears in the iMovie Documents pane when copying is complete.
    Open iMovie on your device; if the marquee screen isn’t showing, tap the My Projects button in the upper-left corner above the viewer.
    Tap the Import button at the bottom of the screen, and then tap the name of the project you want to import.When the import is complete, the project opens and can be edited like any other project.

  • I use Adobe Premiere Elements 11. I want to make a Credit Roll and start off screen and stop with the credit remaining still in the middle of the screen. I know this can be done with CS6. Can this be done in Elements 11? Does Elements 12 or 13 have these

    I use Adobe Premiere Elements 11. I want to make a Credit Roll and start off screen and stop with the credit remaining still in the middle of the screen. I know this can be done with CS6. Can this be done in Elements 11? Does Elements 12 or 13 have these options for Credit Roll.

    stevel
    Please read my work on this topic which involves Premiere Elements Preroll and Postroll settings.
    ATR Premiere Elements Troubleshooting: PE: Preroll and Postroll Options Interpreted
    Especially the section relating to Titler, Roll and Crawl Titles.
    Please let us know if that worked for you.
    Thank you.
    ATR

  • I want to use 2 ipads with garageband and irig and headphones and jam with a friend without annoying the neighbours.  Can this be done?

    HI, my friend and I want to jam silently using guitars, garageband, irig and headphones.  Can this be done? when setting up the leader's metronome can be heard, but that's it.  nothing else is heard bbetween the ipads.  any advice is welcome.  thanks.  Jeff

    stevel
    Please read my work on this topic which involves Premiere Elements Preroll and Postroll settings.
    ATR Premiere Elements Troubleshooting: PE: Preroll and Postroll Options Interpreted
    Especially the section relating to Titler, Roll and Crawl Titles.
    Please let us know if that worked for you.
    Thank you.
    ATR

  • HT1438 I would like to use my Ipad mini to connect to a project can this be done?

    I would like to use my ipad mini to connect to a projector can this be done?

    Depends on the projector.
    You can connect via a cable or wireless using an Apple TV.
    http://ipad.about.com/od/iPad_Guide/a/How-To-Connect-Your-Ipad-To-Your-Tv.htmhttp://ipad.about.com/od/iPad_Guide/a/How-To-Connect-Your-Ipad-To-Your-Tv.htm
    Connect an iPad to a Television or Projector
    http://www.everymac.com/systems/apple/ipad/ipad-faq/how-to-connect-ipad-to-tv-te levision-projector.htmlhttp://www.everymac.com/systems/apple/ipad/ipad-faq/how-to-connect-ipad-to-tv-te levision-projector.html
    Connecting iPad iPhone or iPod to TV or Projector
    http://www.disabled-world.com/assistivedevices/computer/ipad-tv.phphttp://www.disabled-world.com/assistivedevices/computer/ipad-tv.php
    iPad Accessories: Connections for a TV or Projector
    http://www.dummies.com/how-to/content/ipad-accessories-connections-for-a-tv-or-p rojector.htmlhttp://www.dummies.com/how-to/content/ipad-accessories-connections-for-a-tv-or-p rojector.html
    You may be interested in AirPlay on the Apple TV:
    http://www.apple.com/airplay/http://www.apple.com/airplay/
    http://www.apple.com/airplay/http://www.apple.com/airplay/
    Alternately, there are Apple Digital AV Adapters for hardwired connections:
    http://support.apple.com/kb/ht4108http://support.apple.com/kb/ht4108
    http://support.apple.com/kb/ht4108http://support.apple.com/kb/ht4108
     Cheers, Tom

  • HT3728 I do not need another wireless network but want to use the airport express for printer access only.  Can this be done and how?

    I do not need another wireless network but want to use the airport express for printer access only.  Can this be done and how?

    You can configure the AirPort Expess to "Join a wireless network" and enable the Ethernet port so that Ethernet devices will be able to connect.
    In order to print from the iOS devices, you will need to have an application like Printopia installed on your Mac. The Mac must be active when you want to print.
    More details here: Printopia - AirPrint to Any Printer - Print from iPad - Print from iPhone ...
    There is a free trial available for Printopia, so make sure that it will work before you buy the AirPort Express.

  • Hi. I have bought both Adobe XI Pro and standard and downloaded only one of them yet. How do i proced to download the other? Can this be done without install or perticipate within Creative Cloud, only by using username and PW?

    Hi.
    I have bought both Adobe XI Pro and standard and downloaded only one of them yet.
    How do i proced to download the other?
    Can this be done without install or perticipate within Creative Cloud, only by using username and PW?

    I assume you have the S/Ns. The download is at http://helpx.adobe.com/acrobat/kb/acrobat-downloads.html. Be sure to backup the download to CD or backup HD for future use.

Maybe you are looking for

  • App store not working after upgrade to Maverick

    i recently upgraded my machine to the latest OS ... but now i am facing a problem where the laptop just freezes ... the app store does not work... Please could you help me... i need some advice ... I have a MAC BOOK late 2008... i love this machine ,

  • TLB VMI Sales orders are not publishing into ECC

    Hello All, I am trying to transfer the VMI Sales orders in TLB Interactive planning from SCM (7.0) to ECC (6.0) without any success.  I am getting the messages "You have selected 0 change pointer", "0 change pointers(s) processed" and "0/1 orders wer

  • My iPod Touch is freezing and rebooting itself.

    Hi. Here's the story: My iPod was recently working yesterday. I left it on the wall charger for a while, and later I come back to find my iPod frozen, out of nowhere. For another while, it freezes and starts to reboot itself. I done all I can. I watc

  • Hp laserjet Pro 200 M276nw won't consistently connect wirelessly with iMac

    I'm on my second brand new hp laserjet Pro 200 M276nw in 3 days, it will not consistently connect wirelessly with my newly purchased (8days old) Apple refurbished 27" iMac on OSX 10.9, i7 chip & Fusion Drive.  The hp laserjet will sometimes connect w

  • Problem in starting Sun Java System Application Server

    Hi, Recently I installed SJSAS 8.1 on my machine (Windoes 2000), before that I was working on SJSAS8.0 and it was working file. But with 8.1 when I try to "Start Default Server". I get the following error on the console: Starting Domain domain1, plea