home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.databases.oracle      Overblown overpriced overengineered SHIT      2,288 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 1,843 of 2,288   
   Agoston Bejo to Agoston Bejo   
   Re: selecting a column according to a mi   
   19 Oct 04 11:12:25   
   
   XPost: comp.databases.oracle.misc, comp.databases.oracle.server   
   From: gusz1@freemail.hu   
      
   Actually, here is what I could come up with:   
      
   select i from   
    (SELECT i, j FROM T WHERE [condition] ORDER BY j )   
   WHERE ROWNUM = 1   
      
   Is this very inefficient?   
      
   "Agoston Bejo"  wrote in message   
   news:cl0atr$9n7$1@news.caesar.elte.hu...   
   > Take a look at the following example:   
   >   
   > table T(i INTEGER, j INTEGER)   
   >   
   > I want to get the value of i where j is minimal and some conditions apply.   
   >   
   > (1)   
   > SELECT i FROM T   
   > WHERE [condition]   
   > AND j   
   > IN (SELECT min(j) FROM T WHERE [condition])   
   >   
   > The best would be if such a syntax was allowed (which it isn't):   
   > SELECT i, min(j) FROM T WHERE [condition]   
   >   
   > How can I rewrite the SELECT statement in (1) such that [condition]   
   doesn't   
   > have to be typed in twice? Or how can I achieve the same thing in some   
   other   
   > way? (I am open to other solutions as well as long as they are inside the   
   > limits of Oracle PL/SQL.)   
   >   
   >   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca