How to reterive just those records where street type is st

IDX     ADDRESS_FORM
1152     326 GREAT EASTERN HIGHWAY
1158     CNR HAMILTON RD & CHARLOTTE ST
1159 34 WESTERN ROAD
SELECT IDX, ADDRESS_foRm FROM TEMP_AU_POI_INTERM WHERE instr(address_form,'ST') >0
MY CONCERN IS THAT I WANT TO REPLACE ST TO STREET JUST IN 2ND RECORD NOT IN FIRST AND THIRD BECASUE THESE ARE PART OF THE NAME WHILE I JUST WANT TO CHANGE STREET TYPE. I WANT TO WRITE A QUERY WHICH SHOULD GIVE ME THE BELOW OUTPUT.
1152     326 GREAT EASTERN HIGHWAY
1158     CNR HAMILTON RD & CHARLOTTE STREET
1159 34 WESTERN ROAD
TO CHANGE ST TO STREET JUST IN 2ND RECORD
THANKS

or, the least fanciest of all, but clean and simple:
SQL> with t as
  2  ( select 1152 idx,'326 GREAT EASTERN HIGHWAY' address from dual union all
  3    select 1158, 'CNR HAMILTON ST & CHARLOTTE ST' from dual union all
  4    select 1159, '34 WESTERN ROAD' from dual union all
  5    select 1196, 'CNR DALGETY RD & NTH STUART HIGHWAY' from dual
  6  )
  7  select idx
  8       , address old_address
  9       , trim(replace(' ' || address || ' ',' ST ',' STREET ')) new_address
10    from t
11  /
IDX OLD_ADDRESS                                        NEW_ADDRESS
#### 326 GREAT EASTERN HIGHWAY                          326 GREAT EASTERN HIGHWAY
#### CNR HAMILTON ST & CHARLOTTE ST                     CNR HAMILTON STREET & CHARLOTTE STREET
#### 34 WESTERN ROAD                                    34 WESTERN ROAD
#### CNR DALGETY RD & NTH STUART HIGHWAY                CNR DALGETY RD & NTH STUART HIGHWAY
4 rijen zijn geselecteerd.Regards,
Rob.

Similar Messages

  • HOW TO SELECT ONLY THOSE RECORDS WHERE NOT AVAILABLE ON SECOND TABLE

    hi
    i have two tables one name is menus and second name is UGroupDetail. Actually i have created it for user role privileges for my application
    USE [LedgerDB]
    GO
    /****** Object: Table [dbo].[Menus] Script Date: 03/28/2015 13:45:27 ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    CREATE TABLE [dbo].[Menus](
    [RightID] [int] NOT NULL,
    [RightName] [nvarchar](200) NULL,
    [GroupID] [int] NULL,
    CONSTRAINT [PK_Menus] PRIMARY KEY CLUSTERED
    [RightID] ASC
    )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
    ) ON [PRIMARY]
    second table is
    USE [LedgerDB]
    GO
    /****** Object: Table [dbo].[UGroupDetail] Script Date: 03/28/2015 13:46:12 ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    CREATE TABLE [dbo].[UGroupDetail](
    [RightID] [int] NOT NULL,
    [RightName] [nvarchar](200) NULL,
    [GroupID] [int] NULL
    ) ON [PRIMARY]
    GO
    ALTER TABLE [dbo].[UGroupDetail] WITH CHECK ADD CONSTRAINT [FK_UGroupDetail_Menus] FOREIGN KEY([RightID])
    REFERENCES [dbo].[Menus] ([RightID])
    ON UPDATE CASCADE
    ON DELETE CASCADE
    GO
    ALTER TABLE [dbo].[UGroupDetail] CHECK CONSTRAINT [FK_UGroupDetail_Menus]
    GO
    ALTER TABLE [dbo].[UGroupDetail] WITH CHECK ADD CONSTRAINT [FK_UGroupDetail_UserGroup] FOREIGN KEY([GroupID])
    REFERENCES [dbo].[UserGroup] ([GroupID])
    ON UPDATE CASCADE
    ON DELETE CASCADE
    GO
    ALTER TABLE [dbo].[UGroupDetail] CHECK CONSTRAINT [FK_UGroupDetail_UserGroup]
    UGroupDetail have many groups as assigned to a new user but Menus table has only default groups which is 90 records
    Menus table is a primary table and UGroupDetail is a Foreign key table
    now i want to combined these tables and want to get only remaining records for each group
    for example i have assigned 5 roles to GroupID 2 and now when i apply select commands the result should be 85 out 90 for GroupID 2
    but i have not idea how to modify select query for get desired result

    I don't really understand the tables. What is GroupID doing in the Menues table? And what does an entry without a RightName mean? Shouldn't that column be NOT NULL?
    The UGroupDetail does not have any primary key. From your description, I would expect the PK to be (RightID, GroupID). But strangely enough, GroupID is nullable. So is RightName, but I think this column is redundant and should be removed.
    Anyway, if I understand your question correctly, you need something like:
    SELECT UG.Name, M.RightName
    FROM   UserGroups UG
    CROSS  JOIN Menus M
    WHERE  NOT EXISTS (SELECT *
                       FROM   UGroupDetail UGD
                       WHERE  UG.GroupID = UGD.GroupID
                         AND  UG.RightID = M.RightID)
    Erland Sommarskog, SQL Server MVP, [email protected]

  • JDBC: How  to select only those records which contains col1 is NULL

    Hi All,
    In JDBC SELECT scenario.
    I wants to select only those records which contains col1 is NULL.
    I am trying as follows:
    <key>
    <col1 isNull="TRUE" />
    </key>
    but in moni/monitoring i am getting Following Error
    006-12-01 19:35:20 Error Unable to execute statement for table or stored procedure. 'BG_SALARY_SEND_SAP_D' (Structure 'SELECT') due to java.sql.SQLException: FATAL ERROR document format: structure 'SELECT', key element 'key' contains no values
    2006-12-01 19:35:20 Error Exception caught by adapter framework: Error processing request in sax parser: Error when executing statement for table/stored proc. 'BG_SALARY_SEND_SAP_D' (structure 'SELECT'): java.sql.SQLException: FATAL ERROR document format: structure 'SELECT', key element 'key' contains no values
    Please suggest how to do select rows with col1 is null.
    Regards

    Rohan,
    isNull= true is used to make the KEY element not mandatory.
    In your case, if the select query is
    select emp from emptest where empno is null
    , then the datatype will be,
    <root>
    <StatementName>
    <dbTableName action=”SELECT”>
      <table>emptest</table>
    <access>
    <emp></emp>
    </access>
    <key1>
    <b><empno hasQuot="NO">is null</empno></b>
    </key1>
    </dbTableName> 
    </StatementName>
    </root>
    I dont have a DB access to try this, but I think this should work.
    If this doesnt work, then you would need to use SQL_QUERY,
    <root>
    <StatementName>
    <anyName action=” SQL_QUERY”>
    <access>select emp from emptest where empno is null</access>
    </anyName > 
    </StatementName>
    </root>
    http://help.sap.com/saphelp_nw04/helpdata/en/2e/96fd3f2d14e869e10000000a155106/content.htm
    Regards,
    Bhavesh

  • How to get count of records for each type from internal table

    Hi Guys,
    I want to implement a logic to find out the count of records in a internal table.
    Assume my internal table have one field having the entries as shown below.
    Internal table Entries
    10
    10
    10
    11
    11
    12
    12
    12
    12
    13
    14
    14
    15
    15
    15
    15
    15
    16
    16
    17
    18
    19
    20
    20
    20
    ....... etc....
    I should get an output as below
    10's - 3
    11's -2 ,
    12's - 4.... etc..
    Could any one help me how to do this.
    Thanx,
    Kumar

    REPORT  zzz.
    DATA: i(100),
          t(100),
          j TYPE n.
    TYPES: BEGIN OF gt_int_type,
            linex(100) TYPE c,
           END OF gt_int_type.
    DATA: gt_int TYPE STANDARD TABLE OF gt_int_type,
          wa_int LIKE LINE OF gt_int.
    START-OF-SELECTION.
      wa_int-linex = '10'.
      APPEND wa_int TO gt_int.
      wa_int-linex = '10'.
      APPEND wa_int TO gt_int.
      wa_int-linex = '10'.
      APPEND wa_int TO gt_int.
      wa_int-linex = '11'.
      APPEND wa_int TO gt_int.
      wa_int-linex = '11'.
      APPEND wa_int TO gt_int.
      wa_int-linex = '12'.
      APPEND wa_int TO gt_int.
      wa_int-linex = '12'.
      APPEND wa_int TO gt_int.
      wa_int-linex = '12'.
      APPEND wa_int TO gt_int.
      wa_int-linex = '12'.
      APPEND wa_int TO gt_int.
      wa_int-linex = '13'.
      APPEND wa_int TO gt_int.
      wa_int-linex = '14'.
      APPEND wa_int TO gt_int.
      wa_int-linex = '14'.
      APPEND wa_int TO gt_int.
      wa_int-linex = '15'.
      APPEND wa_int TO gt_int.
      wa_int-linex = '15'.
      APPEND wa_int TO gt_int.
      wa_int-linex = '15'.
      APPEND wa_int TO gt_int.
      wa_int-linex = '15'.
      APPEND wa_int TO gt_int.
      wa_int-linex = '15'.
      APPEND wa_int TO gt_int.
      wa_int-linex = '16'.
      APPEND wa_int TO gt_int.
      wa_int-linex = '16'.
      APPEND wa_int TO gt_int.
      wa_int-linex = '17'.
      APPEND wa_int TO gt_int.
      wa_int-linex = '18'.
      APPEND wa_int TO gt_int.
      wa_int-linex = '19'.
      APPEND wa_int TO gt_int.
      wa_int-linex = '20'.
      APPEND wa_int TO gt_int.
      wa_int-linex = '20'.
      APPEND wa_int TO gt_int.
      wa_int-linex = '20'.
      APPEND wa_int TO gt_int.
      LOOP AT gt_int INTO wa_int.
        WRITE:/ wa_int-linex.
      ENDLOOP.
      ULINE.
      SKIP 3.
      SORT gt_int BY linex.
      READ TABLE gt_int INDEX 1 INTO i.
      j = 0.
      LOOP AT gt_int INTO wa_int.
        IF wa_int-linex EQ i.
          j = j + 1.
        ELSE.
          WRITE:/ i,'''s = ', j.
          j = 1.
          i = wa_int-linex.
        ENDIF.
      ENDLOOP.
      WRITE:/ i,'''s = ', j.
    consider clearing leading/trainling spaces...

  • Fetch records where there is increase in Total_Sales.

    I have table like :-
    Year Month Total_sales
    2001     1     50000
    2001     2     50000
    2001     3     50000
    2001 4     50000
    2001     5     60000
    2001     6     70000
    2001     8     80000
    2001     7     70000
    I need the output like
    Year Month Total_sales
    2001     1     50000
    2001     5     60000
    2001     6     70000
    2001     8     80000
    It means, I want only those records where there is increase in Total_Sales.

    SQL> With Data As
      2  (Select 2001 Year, 1 Month,  50000 Total_Sales From Dual Union All
      3  Select 2001, 2, 50000 From Dual Union All
      4  Select 2001 ,3, 50000 From Dual Union All
      5  Select 2001, 4, 50000 From Dual Union All
      6  Select 2001, 5, 60000 From Dual Union All
      7  Select 2001, 6, 70000 From Dual Union All
      8  Select 2001, 8, 80000 From Dual Union All
      9  Select 2001, 7, 70000 From Dual
    10  )
    11  Select * From (
    12                 Select Year,
    13                        Month,
    14                        Case
    15                        When Row_Number() Over(Order By Month) = 1 Then
    16                        Total_Sales
    17                        When (Lag(Total_Sales,1,Total_Sales) Over (Order By Total_Sales) < Total_Sales) Then
    18                                                             Total_Sales
    19                                                             Else
    20                                                             Null
    21                                                             End
    22                        Total_Sales
    23                                                      From Data
    24                                                      )
    25  where total_sales is not null;
          YEAR      MONTH TOTAL_SALES
          2001          1       50000
          2001          5       60000
          2001          6       70000
          2001          8       80000
    SQL>

  • Select single record per distinct type

    My test table is shown below, I needed to return just ONE invoice for each distinct prov_type
    PROV_TYPE INVOICE
    E 111
    E 222
    E 333
    AL 444
    I could use: SELECT distinct prov_type,
    min(invoice)
    FROM test_table
    Yields (one invoice per prov_type):
    Prov_type Invoice
    E 111
    AL 444
    But to extend this, how would I get the same result when
    there are more than just the 2 columns (prov_type and invoice)?
    Example data (selected from numerous tables):
    PROV_TYPE INVOICE SOME_DATES SCHEDULE
    E 111 JUNE 1 40A
    E 222 JUNE1 7A-C
    E 333 MAY 1 20C
    AL 444 JULY 1 7C-R
    I'm trying to select ONE invoice example of
    each prov_type.
    Is there any way to write something to
    get one record of each type of prov_type?....without having to execute the
    underlying where clause twice (once to get the distinct prov type and min
    invoice, and one to get the rest of the data for the invoice???)? I'm wondering this
    because the underlying where clause to get the above data set could be slow.
    I keep thinking there should be some way to select the above data set, and
    then somehow use a subquery or rownum or count(*) or something else to pick and choose the
    records I want from this set.
    Also, I have something similar to this where I select a bunch of data, and I
    want one record where a type column = R and one record where the same type
    column is NOT R. Same idea.. is there any way to select the "bunch of
    data" one time and manipulate the result set? Or do I have to:
    SELECT a_bunch_of_data
    FROM a_bunch_of_tables
    WHERE a_bunch_of_conditions
    AND the_type = 'R'
    AND rownum < 2
    UNION
    SELECT a_bunch_of_data (AGAIN)
    FROM a_bunch_of_tables (AGAIN)
    WHERE a_bunch_of_conditions (AGAIN)
    AND the_type <> 'R'
    AND rownum < 2

    Using PL/SQL AND/OR Dynamic SQL can simplify this. If your requirement
    is strictly SQL however, and your main goal is not to have to join
    anything else to your view, one (tricky) way would involve the following:
    1. get the data length of each needed column (except the key column) from the table definition.
    2. convert each of these column into character type, left padded to its data length
    3. concatenate these columns, with the target column in the front (e.g. Invoice Number)
    4. Apply the group function on the concatenated string, grouping by the key column.
    5. parse the string back
    This shouldn't be bad if you have to set it up only once!
    Note: for the second problem, you can use the same technique, with:
    GROUP BY DECODE(the_type,'R','R','Not R')
    CREATE TABLE test_table (
    PROV_TYPE VARCHAR2(10),
    INVOICE NUMBER,
    SOME_DATE DATE,
    SCHEDULE VARCHAR2(20),
    some_num_field NUMBER(5,3)
    INSERT INTO test_table VALUES('E',111,TO_DATE('JUN 1','MON DD'),'40A',12.123);
    INSERT INTO test_table VALUES('E',22,TO_DATE('JUN 1','MON DD'),'7A-C',3.04);
    INSERT INTO test_table VALUES('E',333,TO_DATE('MAY 1','MON DD'),'20C',1.4);
    INSERT INTO test_table VALUES('AL',444,TO_DATE('JUL 1','MON DD'),'7C-R',9);
    INSERT INTO test_table VALUES('Z',9,TO_DATE('JUL 1','MON DD'),'7C-R',12.123);
    INSERT INTO test_table VALUES('Z',123,TO_DATE('JUL 1','MON DD'),'7C-R',12.123);
    INSERT INTO test_table VALUES('Z',999,TO_DATE('JUL 1','MON DD'),'7C-R',99.999);
    SELECT
    PROV_TYPE,
    TO_NUMBER(SUBSTR(
    MIN(LPAD(invoice,38) &#0124; &#0124; TO_CHAR(some_date,'YYYYMMDDHH24MISS') &#0124; &#0124;
    LPAD(schedule,20) &#0124; &#0124; LPAD(some_num_field,39)),
    1,38)) invoice,
    TO_DATE(SUBSTR(
    MIN(LPAD(invoice,38) &#0124; &#0124; TO_CHAR(some_date,'YYYYMMDDHH24MISS') &#0124; &#0124;
    LPAD(schedule,20) &#0124; &#0124; LPAD(some_num_field,39)),
    38+1,14),'YYYYMMDDHH24MISS') some_date,
    LTRIM(SUBSTR(
    MIN(LPAD(invoice,38) &#0124; &#0124; TO_CHAR(some_date,'YYYYMMDDHH24MISS') &#0124; &#0124;
    LPAD(schedule,20) &#0124; &#0124; LPAD(some_num_field,39)),
    38+14+1,20)) schedule,
    TO_NUMBER(SUBSTR(
    MIN(LPAD(invoice,38) &#0124; &#0124; TO_CHAR(some_date,'YYYYMMDDHH24MISS') &#0124; &#0124;
    LPAD(schedule,20) &#0124; &#0124; LPAD(some_num_field,39)),
    38+14+20+1,39)) some_num_field
    FROM test_table
    GROUP BY prov_type
    /null

  • HT204380 How can I filter my 500+ email contacts to just those I can facetime chat with?

    How can I filter my 500+ email contacts to just those I can facetime chat with?

    You will need to remove it as your rescue email : log into your account via the 'manage your apple id' button on http://appleid.apple.com, select the 'Password And Security' section on your account's screen, and answer the two security questions that show - you should then be taken to another screen where you can change or remove your rescue email address.
    Then try logging out of your account and then log back in and see if you can then use it as your primary email address.

  • The app icons and font on my iPhone 4 just went to massive making it difficult to even scroll how can I change it back, where do I go which menu? Thanks in advance

    The app icons and font on my iPhone 4 just went to massive making it difficult to even scroll how can I change it back, where do I go which menu? Thanks in advance

    Next time you accidentally use 3 fingers it will zoom again. Unless you need the feature you're better to turn it off

  • My dad and I have shared an iTunes account for years and I just created a new apple id but I have no Idea how to get all those purchases to this new account. Help please?

    My dad and I have shared an iTunes account for years and I just created a new apple id but I have no Idea how to get all those purchases to this new account. Help please?

    The old Apple ID (presumably your dads) owns those songs and your new Apple ID does not.  However, your dad can authorize your iD to use the songs by going to Store > Authorize This Computer from your iTunes menu and entering his Apple ID and password.

  • I just purchased a MacBookPro after having a MacBook.  I have ILife, IWorks and Office for Mac.  How do I get those programs on to my MacBook Pro?  I will still use my MacBook at work so I need those programs to remain on it as well.

    I just purchased a MacBookPro after having a MacBook.  I have ILife, IWorks and Office for Mac.  How do I get those programs on to my MacBook Pro?  I will still use my MacBook at work so I need those programs to remain on it as well.

    You need a Firewire cable to run between the two Macs.  Using Utility>Migration Assistant running on your new MacBook Pro, transfer what you want (with all the preferences and such) from your MacBook to your MBP.  Here's more info from Apple.
    You might have an issue with the Serial number for Office, but hopefully you have that around.
    Hope this helps.

  • I just bought a (used) Iphone 3gs for wife and it had angry birds and $89 Navigation on it (I paid extra for it).  Once updated and logged into my I-tunes it no longer works? How can I make those apps work?

    I just bought a (used) Iphone 3gs for wife and it had angry birds and $89 Navigation on it (I paid extra for it).  Once updated and logged into my I-tunes it no longer works? How can I make those apps work?

    Apple doesn't have anything to do with this other than enforcing the DRM protection. The developers of this content expect to be paid if someone wants to use their content. When you purchase content in the app store, you purchase a license to use the content. This license does not permit you or anyone else to resell or give this content away. The individual you purchased the phone from simply does not have the right to sell or give away any purchased content on the phone. You were deceived.

  • HT203167 I have just downloaded the latest itunes version (11.0.1). All my data cannot now be located, though the library is showing all the correct content.The data is stored on an external hard drive. How do I tell the library where to find it's data?

    I have just downloaded the latest itunes version (11.0.1). All my data cannot now be located, though the library is showing all the correct content.The data is stored on an external hard drive. How do I tell the library where to find it's data?

    The iTunes application should be installed on the system drive. You may need to repair iTunes to fix that error regarding a missing .exe.
    To organize your library properly see Make a split library portable.
    If you don't have a working version of the library that can be transformed into a portable shape I have tools and techniques that can repair the broken links.
    tt2

  • I just added my Facebook contacts with my iphone Contacts, how can I include those in my mac Contacts?

    I just added my Facebook contacts with my iphone Contacts, how can I include those in my mac Contacts?

    I did that, but the recently added FB contacts in my iphone are not on my mac's contacts.

  • When going from a Mac-based Ai to a PC based Ai, the documents "Font" are not found on the PC version?  (mostly Helvetica) where and how do I get those Fonts?  And/or, can I use the Mac version of these Fonts?

    When going from a Mac-based Ai to a PC based Ai, the documents "Font" are not found on the PC version?  (mostly Helvetica) where and how do I get those Fonts?  And/or, can I use the Mac version of these Fonts?
    Thanks, Rich

    In order to be cross platform you must be using the Open Type version of all fonts to cause the least disruption. Macs can read and process the Windows .ttf  type format but PCs can't process Mac formatted type. Most recent versions also cannot use the older PS Type 1 fonts.

  • I DON'T SEE FIREFOX ICONS OR FOLDER IN START MENU, DESK TOP OR TASK BAR. HOW CAN I INSTALL THOSE? OR WHERE I CAN START FIREFOX BROWSER?

    I DON'T SEE FIREFOX ICONS OR FOLDER IN START MENU, DESK TOP OR TASK BAR. HOW CAN I INSTALL THOSE? OR WHERE I CAN START FIREFOX BROWSER?
    How can I start or open Firefox?

    HI SBPARK,
    When you installed Firefox, did you uncheck the option to create a short cut?
    In order to pin to the toolbar, when you have Firefox open, right click on the icon in the bar and select "Pin to task bar".

Maybe you are looking for