Any other way to achieve this?

SQL> desc cname
Name Null? Type
ID NUMBER
CTYPE VARCHAR2(10)
CLIAS VARCHAR2(10)
SQL> select *from cname;
ID CTYPE CLIAS
11 acn tst
12 acn tst
12 ucp nbs
12 asf trp
SQL> ed
Wrote file afiedt.buf
1 select a.id,a.ctype,a.clias from cname a, cname b
2 where
3 a.ctype = b.ctype and
4 a.clias = b.clias and
5* a.rowid!=b.rowid
SQL> /
ID CTYPE CLIAS
12 acn tst
11 acn tst
SQL>
Any other way to achieve the above output?
Thanks. :-)

Maybe
select id,ctype,clias
  from cname
where (ctype,clias) in (select ctype,clias
                           from cname
                          group by ctype,clias
                          having count(*) > 1
                        )Regards
Etbin
NOT TESTED as I don't have database access on weekends/holidays

Similar Messages

  • How to create a function with dynamic sql or any better way to achieve this?

            Hello,
            I have created below SQL query which works fine however when scalar function created ,it
            throws an error "Only functions and extended stored procedures can be executed from within a
            function.". In below code First cursor reads all client database names and second cursor
            reads client locations.
                      DECLARE @clientLocation nvarchar(100),@locationClientPath nvarchar(Max);
                      DECLARE @ItemID int;
                      SET @locationClientPath = char(0);
                      SET @ItemID = 67480;
       --building dynamic sql to replace database name at runtime
             DECLARE @strSQL nvarchar(Max);
             DECLARE @DatabaseName nvarchar(100);
             DECLARE @localClientPath nvarchar(MAX) ;
                      Declare databaselist_cursor Cursor for select [DBName] from [DataBase].[dbo].
                      [tblOrganization] 
                      OPEN databaselist_cursor
                      FETCH NEXT FROM databaselist_cursor INTO @DatabaseName
                      WHILE @@FETCH_STATUS = 0
                      BEGIN       
       PRINT 'Processing DATABASE: ' + @DatabaseName;
        SET @strSQL = 'DECLARE organizationlist_cursor CURSOR
        FOR SELECT '+ @DatabaseName +'.[dbo].[usGetLocationPathByRID]
                                   ([LocationRID]) 
        FROM '+ @DatabaseName +'.[dbo].[tblItemLocationDetailOrg] where
                                   ItemId = '+ cast(@ItemID as nvarchar(20))  ;
         EXEC sp_executesql @strSQL;
        -- Open the cursor
        OPEN organizationlist_cursor
        SET @localClientPath = '';
        -- go through each Location path and return the 
         FETCH NEXT FROM organizationlist_cursor into @clientLocation
         WHILE @@FETCH_STATUS = 0
          BEGIN
           SELECT @localClientPath =  @clientLocation; 
           SELECT @locationClientPath =
    @locationClientPath + @clientLocation + ','
           FETCH NEXT FROM organizationlist_cursor INTO
    @clientLocation
          END
           PRINT 'current databse client location'+  @localClientPath;
         -- Close the Cursor
         CLOSE organizationlist_cursor;
         DEALLOCATE organizationlist_cursor;
         FETCH NEXT FROM databaselist_cursor INTO @DatabaseName
                    END
                    CLOSE databaselist_cursor;
                    DEALLOCATE databaselist_cursor;
                    -- Trim the last comma from the string
                   SELECT @locationClientPath = SUBSTRING(@locationClientPath,1,LEN(@locationClientPath)-  1);
                     PRINT @locationClientPath;
            I would like to create above query in function so that return value would be used in 
            another query select statement and I am using SQL 2005.
            I would like to know if there is a way to make this work as a function or any better way
            to  achieve this?
            Thanks,

    This very simple: We cannot use dynamic SQL from used-defined functions written in T-SQL. This is because you are not permitted do anything in a UDF that could change the database state (as the UDF may be invoked as part of a query). Since you can
    do anything from dynamic SQL, including updates, it is obvious why dynamic SQL is not permitted as per the microsoft..
    In SQL 2005 and later, we could implement your function as a CLR function. Recall that all data access from the CLR is dynamic SQL. (here you are safe-guarded, so that if you perform an update operation from your function, you will get caught.) A word of warning
    though: data access from scalar UDFs can often give performance problems and its not recommended too..
    Raju Rasagounder Sr MSSQL DBA
          Hi Raju,
           Can you help me writing CLR for my above function? I am newbie to SQL CLR programming.
           Thanks in advance!
           Satya
              

  • Is there any other way to achieve per user call forward restriction other than to create multiple voice policies?

    Hello,
    We mentioned the environment details below:
    Environment
    In our PBX environment, currently a user can forward calls to any local (within a region) internal extension. But for external PSTN call forwarding, a user needs to send a request and be approved by their manager. And the forwarding restriction
    is applied such that user is only allowed to forward to that particular PSTN number - to prevent toll fraud.
    Moving forward to Lync, using voice policy's call forwarding and simultaneous ring PSTN usages, I can set it to allow forward and simultaneous ring to custom PSTN usage and a custom route that will only send calls to these pre-approved
    external numbers.
    Outcome
    But in such a scenario,
     sSince all the custom external allowed numbers will have to be put into a single Route match table, User A will be able to successfully
    set up call forward to User B's number. (if they come to know about it somehow, that is)
    rü 
    Route matching list will be very long due to the number of users per hubsite that has call forwarding enabled.
    Questions
    Is there any other way to achieve per user call forward restriction other than to create multiple voice policies ? MSPL may be ?  
    2. Is there a limit in the number of entries you can have on the Route pattern matching regex expression ?
    Please advise. MANY THANKS.

    1) I think multiple policies may be your best bet, though it's not a fun one to manage, I agree.  MSPL could do it, but it would be more complex to maintain in the end.  Even gateways have limitations on routes.
    2) I'm not aware of a limit, though I'm not saying there's isn't one.  But if you hit it, you could move to a second usage/route combo.
    I'd suggest building out some PowerShell usage/route creation/organization script for this so it's not something that would need to be maintained within the GUI.
    Please remember, if you see a post that helped you please click "Vote As Helpful" and if it answered your question please click "Mark As Answer".
    SWC Unified Communications
    This forum post is based upon my personal experience and does not necessarily reflect the opinion or view of Microsoft, its employees, or other MVPs.

  • My ipad2 freezes when i try to delete a email that has a 78mb pdf attached. Is there any other way to delete this file other than through the email program?

    My ipad2 freezes when i try to delete a email that has a 78mb pdf file attatched. Is there any other way to delete this file other than the email program?

    If it's not MobileMe, use Safari to access the server directly and delet from there. If it is MobileMe, do the same thing but from your computer as the iPad Safari won't connect to MobileMe mail.

  • My video needs to go on a SD DVD single layer-it is 1h 51m long-the only way I can make is fit is encode H. 264-not ideal-I am using the Share option in FCP-native media was shot 980x720...any other way to do this??

    My video needs to go on a SD single layer DVD…it is 1h 51m long…the only way I can make it fit is encode H. 264…not ideal…I am using the Share option in FCP…native media was shot 980x720...any other way to do this??

    To play on DVD Players, it has to be MPEG2.
    It's under 2 hours; I'm surprised it won't fit. If not, get Compressor and lower the bit rate to fit.
    The native resolution was 980X720…you mean 960?
    It will all be resized to 720X480, which is DVD standard.
    Russ

  • I can't activate my iphone because my cousin's account was hacked. Is there any other way to fix this?

    my aunt got my cousin a new iphone, so she gave me my cousin's old iphone. I reset the the phone she gave me so i can set it up for my own use now. The problem is that i need the account of my cousin in order to activate the phone, the bad news is that her account was hacked. Is there any other way that i can activate this account and put it on my list of devices? So that if i want to reset it, i'll just use my account to activate it.
    P.S.
    i Do have a proof that this phone was given to me by my aunt and she is the one who bought it for my cousin.

    Your cousin needs to contact Apple and ask to speak to someone in account security to get the Apple ID back under his/her control.
    If your aunt has original proof of purchase for the phone, she can bring that, along with the phone, to an Apple store or call Apple and they may be able to assist.
    ~Lyssa

  • Installed successfully but network is not connected. Yet when I go on my Mac network is connected. Is there any other way to solve this problem? Please help.

    Hi,
    I have just installed Windows 7 Home Premium on my Mac book Pro 13inch, it installed successfully but there is no network connection. Yet when I go on my Mac I can get online no problem. Please help or what other way I can do to connect windows online?

    Did you download Windows Support Software when you started installing windows via Bootcamp. If yes you need to then install the Support Software after installing windows which contains Windows drivers for Mac hardware.

  • Any other way to write this using nvl(x,v) locator.

    please solve my confusion.
    select * from emp
    where nvl(to_char(temperature),'a')
    in (select nvl(to_char(temperature),'a') from emp
    where ename = 'SCOTT');
    temperature column in numeric value. Is there anyother way to execute the same answer without using type casting(to_char).
    can we use above queries ans without to_char..
    Edited by: user8710598 on Aug 19, 2009 10:18 AM

    Hi Solomon,
    I think you are forgot one case ( if sal is null).
    Sincerly it's good solution Solomon, I learned a good method to avoid scan table two times.
    Tanks Solomon.
    Good job.
    SELECT *
      FROM (SELECT e.*,
                   MAX (CASE
                           WHEN ename = 'SCOTT' OR temperature IS NULL
                              THEN 1
                        END
                       ) OVER (PARTITION BY temperature) scotts_temperature_club
              FROM emp e)
    WHERE scotts_temperature_club = 1
    SELECT *
      FROM emp_test;
         EMPNO ENAME      JOB              MGR HIREDATE          SAL       COMM     DEPTNO
          7369 SMITH      CLERK           7902 1980-12-17        800                    20
          7499 ALLEN      SALESMAN        7698 1981-02-20       1600        300         30
          7521 WARD       SALESMAN        7698 1981-02-22       3000        500         30
          7566 JONES      MANAGER         7839 1981-04-02                               20
          7654 MARTIN     SALESMAN        7698 1981-09-28       1250       1400         30
          7698 BLAKE      MANAGER         7839 1981-05-01                               30
          7782 CLARK      MANAGER         7839 1981-06-09       2450                    10
          7788 SCOTT      ANALYST         7566 1987-04-19       3000                    20
          7839 KING       PRESIDENT            1981-11-17       5000          0         10
          7844 TURNER     SALESMAN        7698 1981-09-08       1500                    30
          7876 ADAMS      CLERK           7788 1987-05-23                               20
          7900 JAMES      CLERK           7698 1981-12-03        950                    30
          7902 FORD       ANALYST         7566 1981-12-03       3000                    20
          7934 MILLER     CLERK           7782 1982-01-23       1300                    10
    SELECT *
      FROM (SELECT e.*,
                   MAX (CASE
                           WHEN ename = 'SCOTT' OR sal IS NULL
                              THEN 1
                        END
                       ) OVER (PARTITION BY sal) scotts_salary_club
              FROM emp_test e)
    WHERE scotts_salary_club = 1
         EMPNO ENAME      JOB              MGR HIREDATE          SAL       COMM     DEPTNO SCOTTS_SALARY_CLUB
          7788 SCOTT      ANALYST         7566 1987-04-19       3000                    20                  1
          7521 WARD       SALESMAN        7698 1981-02-22       3000        500         30                  1
          7902 FORD       ANALYST         7566 1981-12-03       3000                    20                  1
          7566 JONES      MANAGER         7839 1981-04-02                               20                  1
          7876 ADAMS      CLERK           7788 1987-05-23                               20                  1
          7698 BLAKE      MANAGER         7839 1981-05-01                               30                  1
    6 rows selected.

  • My ipad was having problems opening viewers, but I learned to power it  off and wait about a minute and turn it back on and it rests the issue, do you have any other ways or ifs this the best it worked pretty good this time, but  if it happens again

    My Ipad has trouble opening setting tab and safari, it opens abd before you can enter anything the iPad shuts it down to the home screen, I mainly use my ipad for the internet or emails, I know the internet works because I still receive emails on it.  Please help me out here.

    Try clearing Safari, close all apps and reset the iPad.
    Go to Settings>Safari>Clear Cookies and Data.
    Tap the home button once. Then tap the home button twice and the recents tray will appear at the bottom of the screen. Tap and hold down on any app icon until it begins to wiggle. Tap the minus sign in the upper left corner of the app that you want to close. Tap the home button twice.
    Reset the iPad by holding down on the sleep and home buttons at the same time for about 10-15 seconds until the Apple Logo appears - ignore the red slider if it appears on the screen - let go of the buttons. Let the iPad start up.

  • I want to reload a Firefox webpage when it is idle for 2 minutes. Is there any add-on ? or any other way to do this.

    I want the page to be reloaded when it is idle for some period of time only. I need a step by step procedure for this.

    https://addons.mozilla.org/en-US/firefox/addon/reloadevery/

  • Why is it like if i don't sync the data in my pad to the itunes of my system ,the data in my ipad is getting cleared when i copy any thing to my ipad.This is not comfortable rite?why is this so.?or there is any other way?

    Why is it like if i don't sync the data in my pad to the itunes of my system ,the data in my ipad is getting cleared when i copy any thing to my ipad.This is not comfortable rite?why is this so.?or there is any other way?

    i noticed this as a bug in iTunes. make sure the correct file is selected in the preferences menus. It does not have to be the default location directiory as Vazandrew stated. your iTunes music library can be anywhere you want it. i have mine on an external cuz i'm a dj and have over 80,000 songs.
    once you select/verify the location of your music library, simply drag the folder into the left panel in iTunes from a finder window. iTunes does not automatically add the items like it use to for some reason.

  • HT1933 Following the instructions above, I'm constantly redirected to this help page rather than receiving any drop down list to select what my problem is. Are there any other ways to report issues with purchases?

    Following the instructions for reporting an issue with a purchase problem, when selecting "report a probelm", I am not provided with a drop down list, I am redirected to the help page instead.
    Is there any other way to report an issue where the app owner has taken the funds twice for the same product at literally the same time?

    To Contact iTunes Customer Service and request assistance
    Use this Link  >  Apple  Support  iTunes Store  Contact

  • I bought this iPhone 5 n its asking for a sim card to activate my phone is there is any other ways to do it?

    i bought this iPhone 5 n its asking for a sim card to activate my phone is there is any other ways to do it?

    No. You can't activate it without a SIM.

  • HT5787 Help, I have forgotten my Apple ID security questions and when i send it to my email address to reset the questions nothing shows up in inbox. Any other way to get past this?

    Help, I have forgotten my Apple ID security questions and when i send it to my email address to reset the questions nothing shows up in inbox. Any other way to get past this?

    You've checked the spam folder on your rescue email account as well as the inbox, and you've tried clicking the reset link a second time ? If you have, and you still haven't received the email, then you will need to contact iTunes Support / Apple to get the questions reset.
    Contacting Apple about account security : http://support.apple.com/kb/HT5699

  • Help, I have forgotten my Apple ID security questions and when i send it to my email address to reset the questions nothing shows up in inbox. Any other way to get past this?

    Help, I have forgotten my Apple ID security questions and when i send it to my email address to reset the questions nothing shows up in inbox. Any other way to get past this?

    Security questions:
    https://discussions.apple.com/docs/DOC-4551
    http://support.apple.com/kb/HT5312
    This is also useful:
    http://www.macworld.co.uk/ipad-iphone/news/?newsid=3463233&olo=email
    If you don’t know your security questions, phone Apple (using the number listed here:  http://support.apple.com/kb/HE57  ) and ask for the Account Security Team.

Maybe you are looking for