Can I query with a select statement in the from statement

I'm working with an application that creates a MASTERTABLE that keeps track of DATATABLEs as it creates them. These data tables are only allowed to be so big, so the data tables are time stamped. What I need to do is to be able to query the MASTERTABLE to find out what the latest datatable is and then query the specific datatable.
I've tried
select count(*) from (select max(timestamp) from mastertable)
and it always comes back with a count of 1.
Is this possible, or is there a better way?

Well, I'm trying to understand... and if I understand, then you need something dynamic. I did create the following example, of course not exactly as yours (I don't have your data). Each employee has a table with his name, containing the sal history, and I want to query that table starting from actual sal :
SCOTT@db102 SQL> select ename from emp where sal= 3000;
ENAME
SCOTT
FORD
SCOTT@db102 SQL> select * from scott;
SAL_DATE         SAL
01-JAN-85       2500
01-JAN-95       2750
01-JAN-05       3000
SCOTT@db102 SQL> set serveroutput on
SCOTT@db102 SQL> declare
  2     v_rc    sys_refcursor;
  3     tname   varchar2(30);
  4     v_date  date;
  5     v_sal   number;
  6  begin
  7     select max(ename) into tname
  8     from emp
  9     where sal = 3000;
10     open v_rc for 'select * from '||tname;
11     loop
12             fetch v_rc into v_date,v_sal;
13             exit when v_rc%notfound;
14             dbms_output.put_line(v_date||' '||v_sal);
15     end loop;
16* end;
SCOTT@db102 SQL> /
01-JAN-85 2500
01-JAN-95 2750
01-JAN-05 3000
PL/SQL procedure successfully completed.
SCOTT@db102 SQL>                                                                          

Similar Messages

  • Can you pass a hidden value along with your select option in the form selec

    Can you pass a hidden value along with your select option in the html form select

    Off topic. Locking.

  • Can not print with HP LaserJet 6L since the upgrade to Mavericks.

    Can not print with HP LaserJet 6L since the upgrade to Mavericks. Any alternative driver for this printer?

    I have an HP LaserJet 5P and had the same problem. My LaserJet is connected to a D-Link ethernet print server, then to an Airport Express to support wireless printing.
    As recommended in earlier posts, I first downloaded the Gutenprint HP drivers at Sourceforge, version 5.2.9 That did not work. Then found the reference to the Apple kb here: http://support.apple.com/kb/dl907
    Downloaded these drivers. When setting up the printer, I got the autoselect option for Generic Postscript Printer and used that. Printer worked, but printed out garbage. I then deleted the printer, and this time selected the HP LaserJet 5P CUPS + Gutenprint v.5.2.9 THAT WORKED! I don't know if was the combination of downloading the drivers from Sourceforge and the Apple kb, or just the Apple kb that solved the problem, but I'm glad this is now sorted.
    I was a bit surprised when I hit this snag to begin with because the last upgrade I did from Lion to Mountain Lion, I did not have this issue. It was seamless.

  • A query with respect to creation of the  shared Objects.

    Hi ,
    I am having a query with respect to creation of the  shared Objects.
    I have seen a example where the Author is creatining Shared Object as shown
    below :
    SharedObj = null;
    sharedObj = SharedObject.getLocal("myTasks");
    and there is nothing related to the word "myTasks" anywhere in the Application .
    Can anybody please let me know what is this word "myTasks" mean here ??
    Thanks in advance .

    hi,
    With a shared object it will create one if it doesn't exist, so "myTasks" will become the shared object name or if it exists it will load any objects that are within that shared object.
    Below is a simple example that uses sharedobjects to store login details.
    http://gumbo.flashhub.net/login/
    David

  • TS1474 I changed my computer (old one is dead!) and now when I want to sync the contents of my iPod onto my new computer, it tells me I can only sync with one computer (i.e. the one that died!) How do I get around this??

    I changed my computer (old Dell is dead!) and now when I want to sync the contents of my iPod onto my new computer (a Sony Vaio), it tells me I can only sync with one computer (i.e. the one that died!) How do I get around this??

    -Transfer iTunes purchases to the compuer by:
    iTunes Store: Transferring purchases from your iOS device or iPod to a computer
    - Transfer other music by using a third-party program like one of those discusssed here:
    Copy music
    - Connect the Ipd to the computer and make a backup by right clicking on the iPod under Devices in iTunes and select Back Up
    - Restore the iPod from that backup
    Note that the backup that iTunes makes does not contain synced media like apps and music.

  • Can two people with their own iPhones use the same computer and iTunes?

    Can two people with their own iPhones use the same computer and iTunes?

    Yes. My wife and I each have our own Apple ID and used the same computer to sync our phones with iTunes. The best way to do this is set up separate user accounts on the computer. If you are logged in to your account on the computer and your wife wants to sync here phone, you would log out and she would log in. These keeps all your stuff separate and avoids a ton of confusion.

  • Can an iphone with a case fit in the michael kors wallet clutch?

    can an iphone with a case fit in the michael kors wallet clutch? I was thinking of getting it but I do not want to take my pittsburgh penguins case off just so it can fit inside of it.

    Yes I saw that article from before. The problem I am having is one that is unique to the PowerMac G5 and does not effect the Mac Pro. The problem I am having is that the PowerMac G5 uses a plastic shield that won't close when you install an Accelero. In order to get this card to work some people have even cut a hole into the shield as you can see with the first picture from this article:
    http://www.xlr8yourmac.com/Graphics/AcceleroS1R2on_ATIX800.html
    Needless to say I feel very uncomfortable doing this. This is why when I came across an article that showed people bending their Acceleros it gave me hope that I could install one with out having to damage my computer and risk having air flow problems. That is why I am wanting to know if bending the Accelero would work like in this forum:
    http://www.silentpcreview.com/forums/viewtopic.php?t=46721

  • How can I record with GarageBand 1.3 in the background using other app?

    How can I record with GarageBand 1.3 in the background using other app?
    I use iPad 2 with iOS 6 and GarageBand v1.3.
    I'd like to play an other app like Sunrizer synth while the GarageBand is recording in the background in a track.
    By now I can do it only using the build-in mic of iPad, but this is not the point.
    Can I record other apps in a GarageBand track?
    Thanks a lot for your time.

    I suspect you are probably correct about the reasoning, although there are already a myriad of ways to do that.
    Don't get me wrong - I never said I like this. But it is consistent with other Apple applications, that are similar restrictive; you cannot take a screenshot, when dvd-player is running for example.
    That are the moments, when I am glad that MacOS X is a unix system under the hood

  • HT1212 It says could not connect to the ipod because it is locked with a passcode. You must enter our passcode on the ipod before it can be used with Itunes. I forgot the passcode so how can I enter/ restore/reset it?

    It says could not connect to the ipod because it is locked with a passcode. You must enter our passcode on the ipod before it can be used with Itunes. I forgot the passcode so how can I enter/ restore/reset it?

    As the linked articl says, place the iOS device in Recovery Mode and then connect to your computer and restore via iTunes. The iPod will be erased.
    iOS: Wrong passcode results in red disabled screen                          
    If recovery mode does not work try DFU mode.                         
    How to put iPod touch / iPhone into DFU mode « Karthik's scribblings         
    For how to restore:
    iTunes: Restoring iOS software
    To restore from backup see:
    iOS: How to back up      
    If you restore from iCloud backup the apps will be automatically downloaded. If you restore from iTunes backup the apps and music have to be in the iTunes library since synced media like apps and music are not included in the backup of the iOS device that iTunes makes.
    You can redownload iTunes purchases by:
    Downloading past purchases from the App Store, iBookstore, and iTunes Store         

  • Can an iPad with iMessage enabled receive a text from an iPhone that has iMessage DISabled?

    Can an iPad with iMessage ENabled receive a text from an iPhone that has iMessage DISabled?

    A "non-iMessage-enabled text) would be an SMS message. iPads do not handle these and they do not go through an Apple server to be "converted". SMS is a function of a cellular carrier, not Apple.

  • How would you change the state to the base state?

    How would you change the state to the base state? Its not
    letting me do something like:
    currentState='<Base State>';

    Sorry about the vagueness of that last reply :)
    What I have done now in my code is this:
    viewstack1.addChildAt(loginCanvas,0);
    toggle.selectedIndex = 0;
    However nothing happens at this line of code:
    toggle.selectedIndex = 0;
    but this works:
    toggle.selectedIndex = 1; or ...
    toggle.selectedIndex = 2;
    toggle.selectedIndex = 3;
    toggle.selectedIndex = 4;
    toggle.selectedIndex = 5;
    toggle.selectedIndex = 6;
    The strange thing is that if I have a button on the screen:
    <mx:Button x="10" y="3" label="Button"
    click="toggle.selectedIndex =0"/>
    and the user clicks it the toggle.selectedIndex = 0; works.
    I'm stumped, any ideas?

  • How to create an ABAP Query with OR logical expression in the select-where

    Hi,
    In trying to create an ABAP query with parameters. So it will select data where fields are equal to the parameters entered. The default logical expression is SELECT.. WHERE... AND.. However I want to have an OR logical expression instead of AND.. how can I attain this??
    Please help me on this.. Points will be rewarded.
    Thanks a lot.
    Regards,
    Question Man

    Hi Bhupal, Shanthi, and Saipriya,
    Thanks for your replies. But that didn't answer my question.
    Bhupal,
    You cannot just replace AND with OR in an ABAP QUERY. ABAP QUERY is a self generated SAP code. You'll just declare the tables, input parameters and output fields to be displayed and it will create a SAP standard code. If you'll try to change the code and replace the AND with OR in the SAP standard code, the system will require you to enter access key/object key for that particular query.
    Shanthi,
    Yes, that is exactly what need to have. I need to retireve DATA whenever one of the conditions was satisfied.
    Saipriya,
    Like what I have said, this is a standard SAP code so we can't do your suggestion.
    I have already tried to insert a code in the ABAP query (there's a part there wherein you can have extra code) but that didn't work. Can anybody help me on this.
    Thanks a lot.
    Points will be rewarded.
    Regards,
    Question Man

  • Report query with multiple selects

    On some of my Report Queries (that have multiple selects) it sometimes changes the rowset when I edit the specific SQL.
    For example, I have 2 selects in my Report Query andnd when I download the XML my first select’s data goes into <ROWSET1> and my second select’s data goes into <ROWSET2>. I then make my template and everything is good.
    But, sometimes when I edit the SQL in the report it changes the ROWSET number of the data so now my first select’s data in ROWSET2. This blows up the report. Is this a bug? Why is it switching the rowsets back and forth?

    I'm referring to the Report queries under shared components.
    My first query is like this:
    select A.emp_id
    from tab1 AC4, tab2 AC3, tab3 AC2, tab4 AC1, tab5 A
    where A.year = :page_year
    and C.FK_SCHOOL IN (SELECT c001
    FROM apex_collections AC1
    WHERE AC1.collection_name = 'SIS_REPORTS_SCHOOLS')
    and nvl(C.ACTIVE,'NONE') IN (SELECT decode(c001,'NONE',nvl(C.ACTIVE,'NONE'),C001)
    FROM apex_collections AC2
    WHERE AC2.collection_name = 'SIS_REPORTS_ACTIVES')
    and nvl(C5.CALENDAR_NO,'NONE') IN (SELECT decode(c001,'NONE',nvl(C5.CALENDAR_NO,'NONE'),C001)
    FROM apex_collections AC3
    WHERE AC3.collection_name = 'SIS_REPORTS_SCHOOL_CALENDAR_NOS')
    and nvl(C10.CLUSTER_CODE,'NONE') IN (SELECT decode(c001,'NONE',nvl(C10.CLUSTER_CODE,'NONE'),C001)
    FROM apex_collections AC4
    WHERE AC4.collection_name = 'SIS_REPORTS_CLUSTER_CODES')
    My second query needs to select the detail info from other tables, but I only want to do it for the (master) records that were returned in the first query.

  • Can CR 2008 with XML ODBC driver using SQL CASE statement?

    Hi:
    when i use SQL Command to provide data to the report from XML file connection. I can not use CASE statement , CR always has error message about "CASE" word.
    I test the same Statement in SQL client connected to Oracle, it runs fine.
    So.. Is it driver's limitation that XML datasource can not use CASE statement inside SQL command window?
    Thanks anyone's reply in advance.
    Johnnychi

    Hi Johnny,
    CR supports what every the ODBC driver supports. The error you are getting is from the XML driver, CR is just passing it through.
    Try using an ODBC to XML driver and then a stand-alone ODBC test tool to see if your SQL works.
    If not you'll have to find another way to use the CASE statement.
    Thank you
    Don

  • Query using flat file in the FROM Statement

    I have a flat file that contains about 10k rows that I need to join to a table with 2million plus rows. My problem is I cannot load the flat file into a Oracle table or create a new table to contain the 10k rows because I lack of permissions to create table on my user account. I have tried using MS-Access to query the two tables using ODBC, but the query times were horribly slow and would time out. I was curious if there is a way of calling the flat file as a table in my SQL statement from Oracle?
    I know the following doesn't work but I was wondering if there is something out there that would allow me to do something like the following?
    example:
    SELECT a.COL1, a.COL2, ff.COLa, FF.COLb
    FROM apple a, c:\temp\flat_file.csv ff
    WHERE a.COLa=ff.COLa
    db version - 10g
    OS - Windows XP Pro
    Thanks in Advance!

    user9339442 wrote:
    I have a flat file that contains about 10k rows that I need to join to a table with 2million plus rows. My problem is I cannot load the flat file into a Oracle table or create a new table to contain the 10k rows because I lack of permissions to create table on my user account. I have tried using MS-Access to query the two tables using ODBC, but the query times were horribly slow and would time out. I was curious if there is a way of calling the flat file as a table in my SQL statement from Oracle?
    I know the following doesn't work but I was wondering if there is something out there that would allow me to do something like the following?
    example:
    SELECT a.COL1, a.COL2, ff.COLa, FF.COLb
    FROM apple a, c:\temp\flat_file.csv ff
    WHERE a.COLa=ff.COLa
    db version - 10g
    OS - Windows XP Pro
    Thanks in Advance!Is there some reason you cannot get the data loaded into the local database?
    If you absolutely cannot (either through creating and loading objects, or having someone else do it for you) i would likely recommend installing your own database (Oracle XE is free and will easily handle your flat file)
    http://www.oracle.com/technetwork/database/express-edition/downloads/index.html
    I would install that, load your data into a schema you create, and then create a database link to the remote database and use that in your query.
    I would highly push you to work with the administrators of the database though and get them to set you up a schema where you can create objects (with access to the objects in other schemas that you require, if only read permitted).

Maybe you are looking for

  • Controlling line item table

    Is there a controlling line item table? Moderator: Please, respect the rules and search SDN before posting

  • Data Separator as semi colon in .CSV

    Hi Guru's, Will it be a problem if I use semi colon as data separator rather than using a comma????

  • TextArea fonts?

    When I use TextArea's setFont() method; TextArea j=new TextArea(); Container content = getContentPane(); JInternalFrame jf=new JInternalFrame("Window", true, true, true, true); jf.setBackground(Color.white); jf.setSize(400,400); desktop=new JDesktopP

  • Help with re-starting my intel imac after 10.4.6 installation?

    Hey guys, I am a UK intel imac user and I have a problem. I upgraded to 10.4.6 via software update this morning and everything seemed to be loading OK. On returning to the computer 5 minutes later I discovered an error message saying that update had

  • SCJA study (requesting suggestions)

    This weekend I took the SCJA and failed with a 54%. While disappointed, I'm more worried about passing next time. Specifically, my weak points were: UML Representation Algorithm Design and Implementation Java Platforms and Integration Technologies Ca