Get row count for different tables to the same line

How can I get the row count for different tables in one line:
SELECT count(A), count(B), count(C) from table tb_a A , tb_b B, tb_c C;
Thanks!

>
Hi,
How can I get the row count for different tables in one line:
SELECT count(A), count(B), count(C) from table tb_a A , tb_b B, tb_c C;Something like this? One of the many uses for CTE's - Common Table Expressions - AKA
subquery refactoring. Worth getting to know - very handy!
with acount as
  select count(*) as counta from dual  -- put your table name here
bcount as
  select count(*) as countb from dual  -- put your table name here
ccount as
  select count(*) as countc from dual  -- put your table name here
select a.counta, b.countb, c.countc from acount a, bcount b, ccount c;HTH,
Paul...
Edited by: Paulie on 25-Jul-2012 17:44

Similar Messages

  • How to get row count(*) for each table that matches a pattern

    I have the following query that returns all tables that match a pattern (tablename_ and then 4 digits). I also want to return the row counts for these tables.
    Currently a single column is returned: tablename. I want to add the column RowCount.
    DECLARE @SQLCommand nvarchar(4000)
    DECLARE @TableName varchar(128)
    SET @TableName = 'ods_TTstat_master' --<<<<<< change this to a table name
    SET @SQLCommand = 'SELECT [name] as zhistTables FROM dbo.sysobjects WHERE name like ''%' + @TableName + '%'' and objectproperty(id,N''IsUserTable'')=1 ORDER BY name DESC'
    EXEC sp_executesql @SQLCommand

    The like operator requires a string operand.
    http://msdn.microsoft.com/en-us/library/ms179859.aspx
    Example:
    DECLARE @Like varchar(50) = '%frame%';
    SELECT * FROM Production.Product WHERE Name like @Like;
    -- (79 row(s) affected)
    For variable use, apply dynamic SQL:
    http://www.sqlusa.com/bestpractices/datetimeconversion/
    Rows count all tables:
    http://www.sqlusa.com/bestpractices2005/alltablesrowcount/
    Kalman Toth Database & OLAP Architect
    SQL Server 2014 Design & Programming
    New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012

  • Trying to get row counts for all tables at a time

    Hi,
    i am trying to get row counts in database at a time with below query but i am getting error:
    its giving me ora-19202 error..please advise me
    select
          table_name,
          to_number(
            extractvalue(
              xmltype(dbms_xmlgen.getxml('select count(*) c from '||table_name))
              ,'/ROWSET/ROW/C')
              count
        from all_tables;

    ALL_TABLES returns tables/views current user has access to. These tables/views are owned not just by current user. However your code
    dbms_xmlgen.getxml('select count(*) c from '||table_name)does not specify who the owner is. You need to change it to:
    dbms_xmlgen.getxml('select count(*) c from '||owner || '.' || table_name)However, it still will not work. Why? As I said, ALL_TABLES returns tables/views current user has access to. Any type of access, not just SELECT. So if current user is, for example, granted nothing but UPDATE on some table the above select will fail. You would have to filter ALL_TABLES through ALL_SYS_PRIVS, ALL_ROLE_PRIVS, ALL_TAB_PRIVS and PUBLIC to get list of tables current user can select from. For example, code below does it for tables/views owned by current user and tables/views current user is explicitly granted SELECT:
    select
          t.owner,
          t.table_name,
          to_number(
            extractvalue(
              xmltype(dbms_xmlgen.getxml('select count(*) c from '||t.owner || '.' || t.table_name))
              ,'/ROWSET/ROW/C')
              count
        from all_tables t,user_tab_privs p
        where t.owner = p.owner
          and t.table_name = p.table_name
          and privilege = 'SELECT'
    union all
    select
          user,
          t.table_name,
          to_number(
            extractvalue(
              xmltype(dbms_xmlgen.getxml('select count(*) c from '||t.table_name))
              ,'/ROWSET/ROW/C')
              count
        from user_tables t
    OWNER                          TABLE_NAME                                                          COUNT
    SCOTT                          DEPT                                                                    4
    U1                             QAQA                                                                    0
    U1                             TBL                                                                     0
    U1                             EMP                                                                     1
    SQL> SY.

  • GETTING ROW COUNTS OF ALL TABLES AT A TIME

    Is there any column in any Data dictionary table which gives the row counts for particular table..
    My scenario is...i need to get row counts of some 100 tables in our database...
    instead of doing select count(*) for each table....is there any way i can do it?
    similary How to get column counts for each table..in database .For example
    Employee table has 3 columns...empid,empname,deptno....i want count(empid),
    count(empname),count(deptno) ...is there any easy way for finding all column counts of each table in data base? is it possible?

    Why does "select count(mgr) from emp" return null and not 13?Good question ;)
    Seems that xml generation in principle can't handle »counting nulls«:
    SQL> select xmltype(cursor(select null c from dual)) x from dual
    X                                                
    <?xml version="1.0"?>                            
    <ROWSET>                                         
    <ROW>                                           
    </ROW>                                          
    </ROWSET>                                        
    1 row selected.
    SQL> select cursor(select count(null) c from dual) x from dual
    Cur

    1 row selected.
    SQL> select xmltype(cursor(select count(null) c from dual)) x from dual
    select xmltype(cursor(select count(null) c from dual)) x from dual
    Error at line 1
    ORA-31011: XML parsing failed
    ORA-19202: Error occurred in XML processing
    LPX-00229: input source is empty
    Error at line 0
    ORA-06512: at "SYS.XMLTYPE", line 0
    ORA-06512: at line 1
    but
    SQL> select xmltype(cursor(select count(1) c from dual)) x from dual
    X                                                
    <?xml version="1.0"?>                            
    <ROWSET>                                         
    <ROW>                                           
      <C>1</C>                                       
    </ROW>                                          
    </ROWSET>                                        
    1 row selected.Looks like a bug to me ...

  • Different zoom levels for different clips in the same project?

    Hi
    I am making a movie with videos from two different cameras. As a result some of the clips are cut down in size to a small portion of the screen. This can be solved if it is possible to use different zoom levels for different clips in the same project. I have not been able to do this. Is it possible?
    kind regards
    Soren

    You can scale the small clips up to the same size of the larger one... but you will get a quality loss.
    Using Motion or Scale to Frame Size commands
    Better to scale the large ones down to a Sequence that matches the smaller clip dimensions.

  • Can you run multiple APEX listeners for different instances on the same server

    Please confirm that we can run multiple APEX listeners for different instances on the same server?  Is it an xml setup configuration or do we need to do more??
    Thank You,
    Tony Miller
    SmartDog Services
    Austin, TX

    Yes.. Just exactly what I was looking for...
    Thanks Jari!!
    Thank You,
    Tony Miller
    SmartDog Services
    Austin, TX

  • Can I display different tables at the same time?

    Hello all,
    This is probably a newbie question but is it possible to display different tables at the same time? I'm using SQL Developer 1.5.5 and I seem to be unable to display more than one table at the same time, whenever i chose to open another table, the old table disappears. In other words, the table display just switches to your new choice in the table list navigator. Any ideas anyone?
    Regards,
    wf

    Menu item "Tools -> Preferences -> Database -> ObjectViewer Parameters"; make sure "Automatically Freeze Object Viewer Windows" is checked.
    HTH.
    Ed. H.

  • How to use the TableSorter for two tables at the same view?

    Hello,
    I am using the TableSorter object in order to sort Dynpro tables.
    Suppose I have two tables at the same view, is it possible to use it seperatly for both of them?
    I assume that at the wdModifyView method I will need to catch the table that the user clicked on, yet I don't have an idea of how to do it...

    Hi Roy,
    Constructor of TableSorter
    public TableSorter(IWDTable table, IWDAction sortAction, Comparator[] comparators)
    So, you have to create instance of TableSorter class for each table on the view.
    best regards, Maksim Rashchynski.

  • About listeners for different databases in the same ORACLE_HOME

    Hello experts, I have a doubt
    I have installed 3 different databases in the same server which OS is Suse Enterprise 10. At this moment I have just one listener that registers all the services. The number of connections are big for two of the three databases so I do not know what might be the best practices for this environment. I have some question I would like you suggestion for me:
    DB version: 11.1.0.7
    Should I have three listener, one for each database?
    Is a good practice to have only one listener for multiple instances in the same server?
    Are there differents between have only one listener for all the instance and have one listener for instance?
    What about the performance?
    Than you in advance, I hope you can guide me.

    Best practice is not to have multiple databases on one server, depending on resources.
    Should I have three listener, one for each database?
    No. That is pretty undesirable and requires more administration.
    Is a good practice to have only one listener for multiple instances in the same server?
    Yes. Remember the listener is only a broker and there are no permanent connections between client, listener and database.
    Are there differents between have only one listener for all the instance and have one listener for instance?
    Yes. The latter is an administration nightmare.
    What about the performance?
    Who cares? The only factors are
    listener.log becomes too big --> set up proper cleanup procedures
    The number of semaphores is exceeded (Unix) or no more threads can be created (Microsoft winblows), which will give rise to ora-12500.
    Sybrand Bakker
    Senior Oracle DBA

  • Updating the photo count for multiple locations of the same keyword

    Is it possible to use a keyword on a photo but have it update other copies of the same keyword in lightroom 2.4? I would like to have linked keywords if this is possible.
    To help understand this better, here is a rough example or what I would like to do.
    I want a generic list of players which in its entirety will contain thousands of names. Then I also want to break those players down into their respective teams/leagues that they played on. This will make the list of players easier to manage when I only have to deal with one team at a time. I also want to seperate by seasons but that is too much for this example. So in my example I have a player who has played in both the AHL and NHL (Daniel Briere).
    Now when I am going through my Flyers photos, I want to keyword a Briere photo. So I drag over the NHL/Philadelphia Flyers/Briere, Daniel keyword. So this gives that keyword a count of 1. I also would like the Briere keyword under Players get updated with a 1. Right now, it won't. How can I link those two? Also, when I go into my Phantoms photos, I see another picture of Briere, I would want to drag over the Teams/AHL/Philadelphia Phantoms/ Briere, Daniel keyword. This would in return update that keyword with a count of 1 and update the Players/Briere, Daniel keyword with a 2 since I now have a single NHL and a single AHL photo of him. Of course I need this behavior to be hierarchial. So if I have a photo of Briere in street clothes, I would want to use the Players/Briere, Daniel keyword. This would then give me a count of 3 but it won't updated the values in NHL and AHL keywords since the Players keyword is in a higher/different location.
    Can this be done?
    Thanks,
    Bob
    P.S. If I made this too confusing, please let me know and I'll try to explain better.
    example of what my keyword list would look like:
    Players
        Briere, Daniel
    Teams
        NHL
            Philadelphia Flyers
                Briere, Daniel
        AHL
            Philadelphia Phantoms
                Briere, Daniel

    You cannot link keywords as you want. Each of those keywords is independent - they just share the same text.
    You can create smart collections which group all occurrences of that name. This is obviously duplication, so you would do it only when you need.
    I suggest you don't try to get too clever with using your keyword hierarchy to represent teams. Instead, use one keyword per individual person, a separate one for each team.You could have a top level keyword teams, and another for people, but don't structure things as you suggest as it leads to confusion about people. When you need to look at one team, use a smart collection that looks for images with Team X, Shot in year Y - the Library Filter  will then break the items down by keyword.
    John

  • How do i create 2 fetch proceess for diffrent table  in the same apge

    hi,
    i create page with 2 from region each region assign to different table each region with DML BUTTON( CREATE,DELETE,UPDATE),there 2 Processes after header to fetch row into two region .now when i run page give me error Column t2 not found in table 1 where the 1st fetch rows Processes fetch data for all item in page Regardless of table name so give me error.
    i mean that
    Region one contain table 1 ....with Fetch row process ( to retrieve data into table 1)
    Region Two Contain table 2....with Fetch row process( to retrieve data into table 2)
    when i run page give me error Column t2 not found in table 1 and when test the sql stetmeni in debug mode i found that the process take all item in page so give this error where column t2 found in table 2 not one ..
    my question
    1- there is any way to assign the Fetch process to specific region so the process take all item in these region only.
    2- how can create manual process to fetch row into specific items in page ( i tray these code
    SELECT col1, col2, col3 ....
    INTO :P1_ITEM1, :P1_ITEM, :P1_ITEM...
    FROM table
    WHERE id = :P_id ) but no data retrieve .
    thanks
    Ahmed
    Edited by: Ahmed.F on Nov 27, 2012 5:10 PM

    my question
    1- there is any way to assign the Fetch process to specific region so the process take all item in these region only.
    2- how can create manual process to fetch row into specific items in page ( i tray these code
    SELECT col1, col2, col3 ....
    INTO :P1_ITEM1, :P1_ITEM, :P1_ITEM...
    FROM table
    WHERE id = :P_id ) but no data retrieve .
    I do not think that it is possible to have more than one Automated Row Fetch process in a given page. See the thread:
    ORA-01403: no data found : Unable to fetch row multiple automated row fetch
    On your second question, the manual process should work provided:
    P_ID has a value when the process executes. You can do it this way:
    i. Make this process as a on-load After/Before header process
    ii. Make sure that P_ID page item has value when the process executes (set it from another page or before the pl/sql process executes)

  • Retrieving data from different tables in the same time crash

    Hi
    this is probably the wrong way to do it, but this is how I did:
    - I wanted a screen with 3 datagrids components retrieving data from 3 different tables.
    - I could make it work while enabling 1 or 2 of them.  When the 3 are enabled, I get this error:
    btw its a huge msg, I will trim it:
    ArgumentError: Can't find ManagedQuery or ManagedOperation named: getItems_paged     at mx.data::RPCDataServiceAdapter/executeQuery()[C:\depot\DataServices\branches\lcds_modeler 101\frameworks\projects\data\src\mx\data\RPCDataServiceAdapter.as:325]     at mx.data::RPCDataServiceAdapter/processDataMessage()[C:\depot\DataServices\branches\lcds_m odeler101\frameworks\projects\data\src\mx\data\RPCDataServiceAdapter.as:920]     at RPCDataServiceRequest/invoke()[C:\depot\DataServices\branches\lcds_modeler101\frameworks\ projects\data\src\mx\data\RPCDataServiceAdapter.as:1668]     at mx.data::DataStore/http://www.adobe.com/2006/flex/mx/internal::invoke()[C:\depot\DataServices\branches\lcds_m odeler101\frameworks\projects\data\src\mx\data\DataStore.as:3343] ...  it continues forever. 
    the getItems_paged is a auto generated function inside the php class flex generates to handle the tables.
    Each of the datagrid is a custom component. I made so to avoid keeping a bunch of code lines in the main 'page'.
    Any suggestion to make it work smoothly?
    Thanks in advance,
    btp~

    Hi
    this is probably the wrong way to do it, but this is how I did:
    - I wanted a screen with 3 datagrids components retrieving data from 3 different tables.
    - I could make it work while enabling 1 or 2 of them.  When the 3 are enabled, I get this error:
    btw its a huge msg, I will trim it:
    ArgumentError: Can't find ManagedQuery or ManagedOperation named: getItems_paged     at mx.data::RPCDataServiceAdapter/executeQuery()[C:\depot\DataServices\branches\lcds_modeler 101\frameworks\projects\data\src\mx\data\RPCDataServiceAdapter.as:325]     at mx.data::RPCDataServiceAdapter/processDataMessage()[C:\depot\DataServices\branches\lcds_m odeler101\frameworks\projects\data\src\mx\data\RPCDataServiceAdapter.as:920]     at RPCDataServiceRequest/invoke()[C:\depot\DataServices\branches\lcds_modeler101\frameworks\ projects\data\src\mx\data\RPCDataServiceAdapter.as:1668]     at mx.data::DataStore/http://www.adobe.com/2006/flex/mx/internal::invoke()[C:\depot\DataServices\branches\lcds_m odeler101\frameworks\projects\data\src\mx\data\DataStore.as:3343] ...  it continues forever. 
    the getItems_paged is a auto generated function inside the php class flex generates to handle the tables.
    Each of the datagrid is a custom component. I made so to avoid keeping a bunch of code lines in the main 'page'.
    Any suggestion to make it work smoothly?
    Thanks in advance,
    btp~

  • HR Authorisation Management for different companies in the same client

    Hi,
    Could anyone please help in this....
    My client has two companies. They want to restrict the authorisation to both the companies so that no one can see each other companies data and at the same time access tha data.
    For Eg, there are two payroll officers, each in both the companies, If i give authorisation to run Payroll driver(PC00_M40_CALC), anyone of them can run payroll for any of the companies. (though,their Payroll area is different). There are many restrictions to be maintained like Maintance of Master data, Maintanance of OM structure as assignement of position, running Payroll, viewing the payslip etc...
    How can this all be restricted so that, the respective  companies can view and access their own data without interfering in to the other company.
    I could only find object P_PYEVRUN which helps me restrict to view the created documents of posting for other company code.
    Can anyone put light on how i should proceed further... I heard we can restrict HR master data, but what all i know is we can restrict at infotype level. My problem is, two persons should access PA30(each from different companies), but should not be able to edit other companies data.
    Thanks
    --Pranitha

    Hi ,
    If you are creating the another company undar the same client . then you can not use different no. range.
    or if you are going different client for different compnay code then you can use different number range for material master.
    SAM

  • Different links for different forms of the same list.

    Greetings,
    I have a custom list created with several columns one of which is the Title column. I have created three different views for this list.
    Using SharePoint Designer 2013 I have created three separate forms, one is a custom new for, a custom edit form and a custom display form. For specific reasons, I have not setup these forms as default. 
    I'd like to change the URL of the Title column depending on the view. 
    For example, if I am on View1 and click on the Title column, then I should see the custom display form I have built. In short, I want a way to manually change the url of the Title column. 
    I plan on creating several other forms for this same list and hence I need to know how I can change the URL of the Title column to match the need of the workflow.
    Thanks in advance.
    Daniel Christian (MCTS)

    May be you can achieve it using different java scipt for different views:
    http://social.msdn.microsoft.com/Forums/sharepoint/en-US/d7083056-594b-45b4-9fd4-9d615cdf5875/how-to-change-link-of-list-items-title-in-sharepoint-custom-list-by-programmatically-on-sharepoint?forum=appsforsharepoint
    However another suggest is that you create multiple title column with different links. every view will have a different title column so it can achieved.

  • Diferent password expiration days for different users in the same system.

    Hi sdn gurus,
    We need to configure different password expiration days for different groups of users in the same system.
    We know how to configure the system to define a password expiration time for the complete system (parameter login/password_expiration_time), but we must configure some expiration time to a group of users and another expiration time to another one in the SAME system.
    Somebody know a way to do this?
    Thanks in advance for your help!!!

    Hi Sunny,
    Thanks for your reply!!!
    We know the parameter is for the complete system ... but we are trying to find out if exist another way to define diferent passwrod expiration days, to diferent group of users (may be with an additional system parameters or UME configuration).
    Thanks to all for your help.

Maybe you are looking for

  • Samsung tv LE32R86BD and mac mini: No Signal

    Hello dear mac users! Today i received my new mac mini (the new model) from the official Apple distributor here in Greece with all the adaptors needed to connect it to my Samsung LE32R86BD tv and that is a mini display port to HDMI adaptor and an HDM

  • Agent disappeared automatically and it appeared in pending management after 6 months.

    We had a server (Windows server 2003 64 bit) which was installed and was working fine. Suddenly it disappeared automatically and it appeared in pending management after 6 months. We noticed it only when it came to pending management that the server d

  • Standard Table to be updated based on User action

    Hi Friends , i have a requirement , its a report and in that based on the user action ( if the user checks a check box that is available in the output screen of the report and saves it)  the value should be updated in a standard table as 'X'. I have

  • Suppress deprecated warning?

    My code is extending an abstract class. In the abstract class they have added a @deprecated tag above the no arg constructor. In my class I'm not defining a no arg constructor and I'm getting the warmingwarning: [deprecation] AbstractAuthenticationTo

  • X2100 Hardware Mirroring

    Hi, I have Windows server (Windows Server Enterprise edition x64 R2 with SP2) installed on SUN Fire X2100 server with single HDD; I wanted to enable the NVIDIA raid controller to have Hardware RAID (mirror). I took the Disk image of the server, conne