Join in sql

hi
i have 2 tables
table A
ID     p_id     loc
1        3122       oh
2        3423        VA
tableB
p_id   p_type 
3122     s
3122      e
i need to join by p_id, but when i am join i am getting 2 rows,i juse need one row whichever comes first
current outout
1          3122              s
1          3122               e
i just need any of 1 row ,s or e whichever comes first, any idea

Hi,
When you join the two tables, you always join on unique keys. In this case you do not have unique values, therefore when you join you will get more outcomes of the same p_id.
If you want to make join, make sure your ID is unique.
With the following example there is a join on the ID column, I have used that column as a unique key. This way you will have from every ID number one line as output.
CREATE TABLE #A
ID INT,
P_ID INT,
LOC VARCHAR(20)
INSERT INTO #A(ID,P_ID,LOC)
VALUES
(1,3122,'OH'),
(2,3423,'VA');
--TRUNCATE TABLE #A
CREATE TABLE #B
ID INT,
P_ID INT,
P_TYPE VARCHAR(20)
INSERT INTO #B(ID,P_ID,P_TYPE)
VALUES
(1,3122,'S'),
(2,3122,'E');
--TRUNCATE TABLE #B
--SELECT * FROM #A
SELECT *
FROM #A
INNER JOIN #B ON #A.ID=#B.ID
This is the output of the above SELECT statement.
Regards,
Reshma
Please Vote as Helpful if an answer is helpful and/or Please mark Proposed as Answer or Mark As Answer when question is answered

Similar Messages

  • Joining v$sql and V$SQL_SHARED_CURSOR in  9.2

    Hi,
    I'm trying to resolve why bind aware statements are not shared , but not sure how to join v$sql V$SQL_SHARED_CURSOR to
    get valuable information .
    Please advice.
    Regards.
    Greg

    GregG wrote:
    Hi,
    I'm trying to resolve why bind aware statements are not shared , but not sure how to join v$sql V$SQL_SHARED_CURSOR to
    get valuable information .
    Please advice.On the combination of SQL_ID and ADDRESS columns?

  • Convert Joins from SQL Server to Oracle

    I am converting a client application's back end from using SQL Server to Oracle. This application provides a GUI that allows people to capture one or more areas of text in a text file and create database tables from these areas. It allows them to perform joins between the tables, etc. I have to convert the area that programatically creates queries behind the scenes to do these joins. Having not done much work with Oracle joins, I'm wondering if someone could show me how I could convert the sample join provided. I can probably handle the rest from there.
    SQL Server Query:
    SELECT
    [T1].[Tk] AS [Tk],
    [T1].[Tk Title] AS [Tk Title],
    [T2].[Rate] AS [Rate],
    [T1].[TotCurHrs] AS [TotCurHrs],
    [T1].[TotCurAmt] AS [TotCurAmt],
    [T1].[TotCaseHrs] AS [TotCaseHrs],
    [T1].[TotCaseAmt] AS [TotCaseAmt],
    [T3].[SortF] AS [SortF]
    FROM
    [T1] FULL JOIN [T2] ON [T1].[Tk] = [T2].[TKName]
    INNER JOIN [T3] ON [T1].[Tk Title] = [T3].[EliteTitle]
    )

    Do as previous colleagues suggested, although you may get the problem with column names. I see at leats one of them has space in it [Tk Title]. So the question is - how you migrated table structure to Oracle? Do the column names are ABSOLUTELY the same as in MS? Then you have to replace brackets with double quotes ", because normally Oracle all identifiers tries to convert to uppercase and also space is not allowed. Only if you use quotes this is possible.
    Gints Plivna
    http://www.gplivna.eu
    Edited by: gintsp on Oct 13, 2010 4:04 PM

  • Cross database join Oracle - SQL server date column - nQSError: 46008

    Hi,
    I am using OBIEE 10.1.3.4.2 and
    I am able to make cross database join between Oracle and SQL server using varchar columns, but I am getting this error:
    nQSError:22024-A comparison is being carried out between noncompatible type when I try to make "foreign key" join between two tables (one from Oracle, second from SQL Server) using number columns (INT, DOUBLE...). It is strange, but I when I make "complex join" on physical layer no error is thrown and everything works fine.
    But I am not able to make join between tables using Date column. Column in Oracle table has DATE datatype, column in SQL server tables has datetimeoffset(7) datatype (example: 2011-07-19 13:14:22.2032605 +02:00). So I tried to cast datetimeoffset(7) to date datatype using "convert(DATE,HappenedOn,120)" - this returns me 2011-07-19 . In this format, BI can show converted date column, I can make filter using this date column, but I am not able to make physical join with Oracle table using this column
    Answer using data from both joined tables gives me this error:
    [nQSError: 46008] Internal error: File .\DataType\SUKeyCompare.cpp, line 875. (HY000)
    Do you have some tips, how to solve this "bug"?

    Parse the command column to get the SSIS package file name may be your only option here.

  • Join v$sql and v$session

    Hi All,
    I want following columns from both v$sql(last_active_time) and v$session(username,status ,program)
    Cud anyone guide me how to what is the sql that joins both views so that i get above column info ?
    Thanks a lot

    sybrand_b wrote:
    Yep but that is a 9i response and it won't work, IIRC, in 10g and higher.
    Sybrand,
    Why it won't work in 10g or higher?
    SQL> /
    Enter value for sid: 138
    old   6:    and ses.sid=&&sid
    new   6:    and ses.sid=138
    SQL_TEXT
    select /*+ ORDERED USE_NL(st) */ sql_text   from v$session ses,
           v$sqltext st   where st.address = ses.sql_address    and
    st.hash_value=ses.sql_hash_value    and ses.sid=138 order by pie
    ce
    SQL> l
      1  select /*+ ORDERED USE_NL(st) */ sql_text
      2    from v$session ses,
      3         v$sqltext st
      4    where st.address = ses.sql_address
      5     and st.hash_value=ses.sql_hash_value
      6     and ses.sid=&&sid
      7* order by piece
    SQL> select * from V$version;
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
    PL/SQL Release 11.2.0.1.0 - Production
    CORE    11.2.0.1.0      Production
    TNS for 32-bit Windows: Version 11.2.0.1.0 - Production
    NLSRTL Version 11.2.0.1.0 - Production
    SQL>Regards
    Aman....

  • Joining Tables SQL SCCM Query

    Hello Im trying to find all users that have Microsoft Project installed I also need their full name not just their user login. I cant see whats wrong with my SQl query? Any help appreciated. I get "Invalid view" error.
    select distinct
    SMS_R_System.Name,
    SMS_R_System.LastLogonUserName,
    SMS_R_System.LastLogonTimestamp,
    SMS_R_System.DistinguishedName,
    SMS_R_System.operatingSystem,
    SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName,
    USR.Full_User_name0
    from
    SMS_R_System
    inner join
    SMS_G_System_ADD_REMOVE_PROGRAMS on
    SMS_G_System_ADD_REMOVE_PROGRAMS.ResourceID = SMS_R_System.ResourceId
    inner join
    v_r_user as USR on
    sys.User_Name0 = USR.User_Name0
    where
    SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName
    like
    "%Project%"
    order by
    SMS_R_System.Name
    SCCM Deployment Technician

    Ah yes now I understand, thankyou for the tip here is the correct code.
    select distinct
    SMS_R_System.Name,
    SMS_R_System.LastLogonUserName,
    SMS_R_System.LastLogonTimestamp,
    SMS_R_System.DistinguishedName,
    SMS_R_System.operatingSystem,
    SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName,
    SMS_R_User.FullUserName
    from
    SMS_R_System
    inner join
    SMS_G_System_ADD_REMOVE_PROGRAMS on
    SMS_G_System_ADD_REMOVE_PROGRAMS.ResourceID = SMS_R_System.ResourceId
    inner join
    SMS_R_User on
    SMS_R_User.UserName=SMS_R_System.LastLogonUserName
    where
    SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName
    like
    "%Project%"
    order by
    SMS_R_System.Name
    SCCM Deployment Technician

  • Cross Join in SQL

    From relational algebra, cross join or cross product or cartesion product is the set of all combinations of tuples in R and S where R and S are relations. Is there anyway I can do the same in SQL?
    Thanks,
    Mustafa

    in oracle 9i u can also say
    select <column list>
    from <table 1> cross join <table 2>
    where <condition>
    here where clause is optional....

  • Need assistance with conditional join in SQL

    Hi All -
    I need to ask for help with this query:
    Create table user_tab_col_test (table_name varchar2(30), column_name varchar2(30), data_type varchar2(30));
    Insert into user_tab_col_test (table_name, column_name, data_type) values ('table1', 'column1', 'varchar2')
    Insert into user_tab_col_test (table_name, column_name, data_type) values ('table1', 'column2', 'varchar2')
    Insert into user_tab_col_test (table_name, column_name, data_type) values ('table1', 'column3', 'varchar2')
    Insert into user_tab_col_test (table_name, column_name, data_type) values ('table1', 'column4', 'varchar2')
    Insert into user_tab_col_test (table_name, column_name, data_type) values ('table2', 'column1', 'varchar2')
    Insert into user_tab_col_test (table_name, column_name, data_type) values ('table2', 'column2', 'varchar2')
    Insert into user_tab_col_test (table_name, column_name, data_type) values ('table2', 'column3', 'varchar2')
    Insert into user_tab_col_test (table_name, column_name, data_type) values ('table2', 'column4', 'varchar2')
    Commit;
    Create table all_cons_columns_test (table_name varchar2(30), column_name varchar2(30), constraint_name varchar2(30))
    Insert into all_cons_columns_test (table_name, column_name, constraint_name) values ('table1', 'column1', 'primary')
    Insert into all_cons_columns_test (table_name, column_name, constraint_name) values ('table1', 'column1', 'secondary')
    Commit;
    This is my query and the current result:
    Select u.table_name, u.column_name, c.constraint_name
    From user_tab_col_test u
    Left outer join all_cons_columns_test c
    On ( u.table_name = c.table_name
    AND U.COLUMN_NAME = C.COLUMN_NAME
    AND C.CONSTRAINT_NAME IN ('primary'))
    order by U.table_name, U.COLUMN_NAME;
    TABLE_NAME COLUMN_NAME CONSTRAINT_NAME
    table1 column1 primary
    table1 column2
    table1 column3
    table2 column1
    table2 column2
    Three questions:
    1) I only want to return results where table_name = 'table1'. I can't seem to get this to work.
    2) Is my query proper and is this the best way to return my desired results? I.e. I want all columns from user_tab_col_test and I only want to display the constraint_name from all_cons_columns_test if the constraint_name = 'primary'.
    3) Will the synatx be the same if I need to join a third table to all_cons_columns_test?
    Any advice/suggestions are much appreciated -
    john
    Edited by: user703358 on Jan 11, 2013 8:57 PM
    Edited by: user703358 on Jan 11, 2013 9:48 PM

    Hi,
    user703358 wrote:
    ... ALL_CONSTRAINTS_TEST joins to ALL_CONS_COLUMNS_TEST on TABLE_NAME and CONSTRAINT_NAME. If you adapt this to use the data dictionary views ALL_CONSTRAINTS and ALL_CONS_COLUMNS, then rememeber to join on the OWNER column, also.
    Ultimately I want to use ALL_CONSTRAINTS_TEST.CONSTRAINT_TYPE = 'P' in my WHERE clause, instead of C.CONSTRAINT_NAME IN (primary), only because the constraint_type is a more definitive attribute than just the name of the constraint.
    I tried something like the query below but I'm getting
    ORA-00904: "U"."COLUMN_NAME": invalid identifier
    00904. 00000 - "%s: invalid identifier"
    *Cause:  
    *Action:
    Error at Line: 8 Column: 16Errors like that are caused by trying to mix old join syntax with ANSI join syntax in the same query.
    SELECT    u.table_name
    ,       u.column_name
    ,       C.CONSTRAINT_NAME
    FROM           USER_TAB_COL_TEST      U,
    ALL_CONSTRAINTS_TEST ACAbove is an example of an old-style join: there is a comma between the table names, and the join conditions are included in the WHERE clause below.
    LEFT OUTER JOIN  all_cons_columns_test  c
    ON    u.table_name    = c.table_name
    AND   U.COLUMN_NAME    = C.COLUMN_NAMEThis is an example of an ANSI-style join: the keyword JOIN appears between the table names, and the join conditions are right here, after the keyword ON.
    WHERE      U.TABLE_NAME    = 'table1'
    AND C.TABLE_NAME = AC.TABLE_NAME
    AND C.CONSTRAINT_NAME = AC.CONSTRAINT_NAME
    and AC.CONSTRAINT_TYPE = 'P'
    ORDER BY  u.table_name
    ,           u.column_name
    ;While it is possible to use both join styles in the same query, it's a really bad idea. I suggest always using ANSI syntax, especially for outer joins, but whatever style you choose, use it consistently for all joins in the same query.
    In this case, you want an inner join between tablec c and ac, so the ANSI syntax would be something like
    FROM  u  LEFT OUTER JOIN c ON ... JOIN ac ON ...In this case, it's very important that the inner join between c and ac is done before the outer join with u. How can you make sure that happens? Well, if you have an arithmetic expression such as
    12 * 5 - 1and you want to make sure the subtraction of 1 from 5 takes place before the multiplication by 12, what do you do? You can add parentheses:
    12 * ( 5 - 1 )In ANSI join syntax, you can use parentheses the same way:
    FROM  u  LEFT OUTER JOIN ( c ON ... JOIN ac ON ... )or, in full:
    SELECT    u.table_name
    ,        u.column_name
    ,        c.constraint_name
    ,       ac.constraint_type
    FROM             user_tab_col_test      u
    LEFT OUTER JOIN  (
                             all_cons_columns_test  c
               JOIN  all_constraints_test   ac
                                 ON   ac.table_name     = c.table_name
                          AND  ac.constraint_name     = c.constraint_name
                            ON    u.table_name       = c.table_name
                   AND   u.column_name       = c.column_name
                   AND   ac.constraint_type  = 'P'
    WHERE       u.table_name     = 'table1'
    ORDER BY  u.table_name
    ,            u.column_name
    ;Output:
    TABLE_NAME COLUMN_NAME CONSTRAINT_NAME CONSTRAINT_TYPE
    table1     column1     primary         P
    table1     column2
    table1     column3
    table1     column4

  • How to join MS SQL Server 2012 to Dreamweaver CS6

    Hello everyone.
    Here's my question: Is it possible to link a Microsoft SQL Server 2012 Database to Dreamweaver CS6, instead of the default MySQL Database?
    I don't particullarily like MySQL because it's interface isn't familiar to me. Instead, I use s way more professional Database Management software, SQL Server 2012. I know that when I try to connect Dreamweaver CS6 to a database, I only have the option to link it to MySQL and I'd like to change it, or at least, to add the SQL Server to the options list. Is there a way to configure that or a kind of Dreamweaver plug-in or extension?
    Please answear.
    Best regards,
    Vlad Drelciuc
    Web Content Developer

    Since you refer to MySQL as the default database, I presume that you're talking about using PHP.
    Yes, you can link to MS SQL Server - as long as you're willing to code everything by hand. If you're looking for automated code generation, though, the answer is no.
    Even the default PHP/MySQL server behaviors are not really worth considering for professional web development. They're fine for quick prototyping, but they use deprecated functions that are not suitable for a production environment.

  • How to write self join in sql?

    Hi,
    I have table named "table_upload", column "record_type" value "01,03,04....." and start_date,end_date and so on
    And i will have value for  start_date,end_date only for record_type=01,rest of type these two columns will be null.
    now i need to write query with self join, to include above concept. can any one please help me .
    and my query look like follows,

    I just want to re write
    Please provide DDL+DML + expected output!
    and short explanation what is it that we all ask you for:
    DDL = Data Definition Language. In our case that is, CREATE TABLE statements for your tables and other definitions that are needed to understand your tables structure and there for let us to test and reproduce the problem in our server. Without DDL no one
    can execute any query.
    How to get DDL: Right click on the table in Object Explorer and select script table as CREATE. Post these create table scripts here.
    DML = data manipulation language is a family of queries used for manipulating the data it self like: inserting, deleting and updating data. In our case we need some sample data in order to check the query and get result, so we need some indert query for
    sample data.
    If you post a "create table query" for the tables and "insert <table> query" with some sample, then we could help you without Assuming/Guessing. There is a reason that DDL is generally asked for and expected when discussing query problems - it helps
    to identify issues, clarify terminology and prevent incorrect assumptions.  Sample data also provides a common point of reference for the discussion. A script that can be used to illustrate or reproduce the issue you have, will encourage others to help.
    [Personal Site] [Blog] [Facebook]

  • How to join multiple SQL statements?

    I'm try to combine four of the following SQL statements as one, and I basically want to group by the new combined sql statement by suspension
    Using: Oracle 10g
    Here's my sql statements/what I've tried but doesn't seem to work:
    select *
    from
    --NBA
    select
           decode (t.league_id, 1 , 'NBA') as League,
           t.moniker as First,
           t.Last_name as Last,
           (t.To_Team_Name || ' ' || To_Team_Nickname) as Team,
           count(*) Suspensions
    from   customer_data.cd_bk_trans t,
           customer_data.cd_bk_roster r
    where  t.player_id = r.player_id
    and    t.trans_type_id in (12,13,14)
    and    r.status = 'Y'
    and    r.league_id = 01
    group by t.league_id,t.last_name, t.moniker, t.to_team_name,t.to_team_nickname
    order by Suspensions desc
    union
    --MLB
    select
           decode (t.league_id, 7 , 'MLB') as League,
           t.moniker as First,
           t.Last_name as Last,
           (t.from_Team_Name || ' ' || from_Team_Nickname)as Team,
           count(*) Suspensions
    from   customer_data.cd_baseball_trans t,
           customer_data.cd_baseball_roster r
    where  t.player_id = r.player_id
    and    t.comments like '%Susp%'
    and    r.status = 'Y'
    and    r.league_id = 07
    group by t.league_id,t.last_name, t.moniker, t.from_team_name,t.from_team_nickname
    order by Suspensions desc
    union
    --NHL
    select
           decode (r.team_id,18, 'NHL') as League,
           t.fn as First,
           t.ln as Last,
           (t.from_Team_Name || ' ' || from_Team_Nickname)as Team,
           count(*) Suspensions
    from   customer_data.cd_nhl_trans t,
           customer_data.cd_nhl_roster r
    where  t.player_id = r.player_id
    and    t.trans_type in (10,11,12)
    and    r.status = 'Y'
    and    r.league_id = 18
    group by r.league_id, t.ln, t.fn, t.from_team_name,t.from_team_nickname
    order by Suspensions desc
    union
    --NFL
    select
           decode (t.league_id, 8, 'NFL') as League,
           t.moniker as First,
           t.last_name as Last,
           (t.from_Team_Name || ' ' || from_Team_Nickname)as Team,
           count(*) Suspensions
    from   customer_data.cd_football_trans t,
           customer_data.cd_football_roster r
    where  t.player_id = r.player_id
    and    t.trans_type_id in (24,25)
    and    r.status = 'Y'
    and    r.league_id = 8
    group by  t.league_id, t.last_name, t.moniker,           t.from_team_name,t.from_team_nickname
    order by  Suspensions desc
    Order by Suspensions desc

    Hi,
    Remove the ORDER BY clause in all the queries expcept lastone. Then it will work.
    You can have the ORDER BY clause in the last query of the inline view. Otherwise it will give the error.
    Run the query given below
    SELECT *
    FROM (
    --NBA
    SELECT decode(t.league_id, 1, 'NBA') AS league,
    t.moniker AS FIRST,
    t.last_name AS LAST,
    (t.to_team_name || ' ' || to_team_nickname) AS team,
    COUNT(*) suspensions
    FROM customer_data.cd_bk_trans t, customer_data.cd_bk_roster r
    WHERE t.player_id = r.player_id
    AND t.trans_type_id IN (12, 13, 14)
    AND r.status = 'Y'
    AND r.league_id = 01
    GROUP BY t.league_id,
    t.last_name,
    t.moniker,
    t.to_team_name,
    t.to_team_nickname
    UNION
    --MLB
    SELECT decode(t.league_id, 7, 'MLB') AS league,
    t.moniker AS FIRST,
    t.last_name AS LAST,
    (t.from_team_name || ' ' || from_team_nickname) AS team,
    COUNT(*) suspensions
    FROM customer_data.cd_baseball_trans t,
    customer_data.cd_baseball_roster r
    WHERE t.player_id = r.player_id
    AND t.comments LIKE '%Susp%'
    AND r.status = 'Y'
    AND r.league_id = 07
    GROUP BY t.league_id,
    t.last_name,
    t.moniker,
    t.from_team_name,
    t.from_team_nickname
    UNION
    --NHL
    SELECT decode(r.team_id, 18, 'NHL') AS league,
    t.fn AS FIRST,
    t.ln AS LAST,
    (t.from_team_name || ' ' || from_team_nickname) AS team,
    COUNT(*) suspensions
    FROM customer_data.cd_nhl_trans t, customer_data.cd_nhl_roster r
    WHERE t.player_id = r.player_id
    AND t.trans_type IN (10, 11, 12)
    AND r.status = 'Y'
    AND r.league_id = 18
    GROUP BY r.league_id,
    t.ln,
    t.fn,
    t.from_team_name,
    t.from_team_nickname
    UNION
    --NFL
    SELECT decode(t.league_id, 8, 'NFL') AS league,
    t.moniker AS FIRST,
    t.last_name AS LAST,
    (t.from_team_name || ' ' || from_team_nickname) AS team,
    COUNT(*) suspensions
    FROM customer_data.cd_football_trans t,
    customer_data.cd_football_roster r
    WHERE t.player_id = r.player_id
    AND t.trans_type_id IN (24, 25)
    AND r.status = 'Y'
    AND r.league_id = 8
    GROUP BY t.league_id,
    t.last_name,
    t.moniker,
    t.from_team_name,
    t.from_team_nickname
    ORDER BY suspensions DESC)
    ORDER BY suspensions DESC

  • JOIN DELETE - SQL

    Is it possible to use a JOIN to delete multiple rows from
    multiple tables
    using a common key?
    Lets say I have 3 tabels (Info, Guests, Host) and they all
    share a common
    column (show_id). I want to remove all the records from each
    table that have
    the same 'show_id'.
    DELETE FROM Info, Guests, Hosts
    WHERE show_id = #URL.show_id#
    Will this work? I don't have a live database to work with at
    the moment and
    I want to start the CFCs for it and came across this
    situation.
    Thanks

    I am a wee bit confused on the <cftransaction> tag. I
    am doing this out of a
    CFC and have all 3 deletes set up in a function. Is that any
    different than
    setting up the 3 deletes in a <cftransaction> tag?
    "Ian Skinner" <[email protected]> wrote in
    message
    news:edsh8n$d0i$[email protected]..
    >I doubt that will work, but I am not sure.
    >
    > If it does not you can use the <cftransaction> tag
    to group all the
    > deletes together so that they all happen or none of them
    happen.
    >
    > <cftransaction>
    > DELETE FROM Info
    > WHERE show_id = #URL.show_id#
    >
    > DELETE FROM Guests
    > WHERE show_id = #URL.show_id#
    >
    > DELETE FROM Hosts
    > WHERE show_id = #URL.show_id#
    > </cftransaction>

  • Can i join these sql select statement in one

    Hi All,
    Can i join this two select statement in to one select statement.
    select username from dba_users where username like 'SAP%%%'; # to the Schemaid of the below /BMC/YGO_CPROD.
    select YOP_PRD_NM, YOP_VERS from <schemaid>."/BMC/YGO_CPROD"; # To know a version from the table.
    I am using this in a script can any help to join the above select statements into one.
    Schemaid should be passed to this select YOP_PRD_NM, YOP_VERS from <schemaid>."/BMC/YGO_CPROD"; and i need to get output!
    Thanks a lot

    Are you asking about using the output of one query as the input to the WHERE clause of another?
    If so look at the demos here: http://www.psoug.org/reference/conditions.html
    PS: There is zero value in the construct 'SAP%%%'
    What is it you are trying to do?
    One "%" wildcard is sufficient.

  • To join the sql query

    Hi All
    Following query is to monitor users tablespace and temp tablesapce. How do I can join these two query as a single query. Kindly assist.
    Users tablespace mon:
    ==============
    select TT.tablespace_name,
    round(TOTAL) TOTAL,
    round(FREE) FREE,
    round(TOTAL - FREE) USED,
    round(100*(TOTAL - FREE)/TOTAL) PCT_USED
    from
    (select tablespace_name, sum(bytes)/1024/1024 FREE
    from dba_free_space group by tablespace_name) FR,
    (select tablespace_name, sum(bytes)/1024/1024 TOTAL
    from dba_data_files group by tablespace_name) TT
    where TT.tablespace_name = FR.tablespace_name(+);
    Temp tablespace mon:
    ===============
    select TT.tablespace_name,
    round(TOTAL) TOTAL,
    round(FREE) FREE,
    round(TOTAL - FREE) USED,
    round(100*(TOTAL - FREE)/TOTAL) PCT_USED
    from
    (select tablespace_name, sum(bytes_free)/1024/1024 FREE
    from v$temp_space_header group by tablespace_name) FR,
    (select tablespace_name, sum(bytes)/1024/1024 TOTAL
    from dba_temp_files group by tablespace_name) TT
    where TT.tablespace_name = FR.tablespace_name(+);

    select TT.tablespace_name,
    round(TOTAL) TOTAL,
    round(FREE) FREE,
    round(TOTAL - FREE) USED,
    round(100*(TOTAL - FREE)/TOTAL) PCT_USED
    from
    (select tablespace_name, sum(bytes)/1024/1024 FREE
    from dba_free_space group by tablespace_name) FR,
    (select tablespace_name, sum(bytes)/1024/1024 TOTAL
    from dba_data_files group by tablespace_name) TT
    where TT.tablespace_name = FR.tablespace_name(+)
    UNION
    select TT.tablespace_name,
    round(TOTAL) TOTAL,
    round(FREE) FREE,
    round(TOTAL - FREE) USED,
    round(100*(TOTAL - FREE)/TOTAL) PCT_USED
    from
    (select tablespace_name, sum(bytes_free)/1024/1024 FREE
    from v$temp_space_header group by tablespace_name) FR,
    (select tablespace_name, sum(bytes)/1024/1024 TOTAL
    from dba_temp_files group by tablespace_name) TT
    where TT.tablespace_name = FR.tablespace_name(+);

  • Join the SQL Server Msdb.dbo.SysJobSteps to the SSIS Package table dbo.sysssispackages

    I have the following query which returns jobs and jobsteps - for those items which have SSIS Packages attached, I would like to include a link to the results of this query below - to the actual SSIS Package Id - Can someone tell me what the column is that
    references the two ?
    dbo.sysssispackages= dbo.SysJobSteps
    I could parse the "command" label - but would prefer something along the lines of job_id unique identifier.
    SELECT
    Job.job_id,
    Job.name,
    Job.enabled,
    Job.description,
    Job.date_created,
    Job.Date_modified,
    Step.Step_Id,
    Step.step_name,
    Step.subsystem,
    Step.command,
    Step.server,
    Step.database_name,
    step.last_run_duration,
    Step.Last_run_date
    FROM Msdb.dbo.SysJobs JOB
    INNER JOIN Msdb.dbo.SysJobSteps STEP ON STEP.Job_Id = JOB.Job_Id
    John

    Parse the command column to get the SSIS package file name may be your only option here.

Maybe you are looking for

  • Are there any tools for data encryption and decryption ?

    Hi, i am using oracle 9i R2, i want encrypt my data. Are there any tools available in market. Please let me know the ways to do data encryption and decryption. Thanks in advance Prasuna.

  • Problem with SP6 + IE + sendRedirect

    Hello,           We've had this problem with the sendRedirect method. Under IE (all versions           we tested), a sendRedirect would take a considerable amount of time to           actually perform the redirection; in fact the time it took was app

  • Connect a VGA monitor to a Macintosh LC III?

    Does anyone know how to connect a VGA monitor to a Macintosh LC III? Thanks!

  • 2.1 RC1 templates converted to lowercase ?

    In 2.1 RC1 I have correctly recovered my templates from 1.5, which are using a mix of lower/uppercase. It is important for me because I have some templates for such things as: call connect_me_to_some_place("IdentiFier MixIng CAseS"); When I auto-comp

  • Selecting Color Balance adjustment layer brings up Levels adjustment layer

    Ok, so, all of a sudden I cannot get a color balance adjustment layer to come up. Every time I do photoshop creates a levels layer. Selecting levels makes a levels layer. All of the other adjustment layers seem to be working normally. How do I fix th