Select in random order?

Is there any way to do a SELECT from a table/view, and tell it to randomize the order the rows are returned in?
TIA -

You can use the following technic:
select *
from emp a,
(select sys.dbms_random.random rnd,
eno
from emp) b
where a.eno=b.eno
order by b.rnd;
Best of Luck
Samujjwal Basu

Similar Messages

  • Random order for a slide show?

    How do you select a random order for a slide show?

    You rang?
    I had actually started working on this sometime in the past when this question was asked before. I never got around to finishing it but I cobbled this together this AM:
    set newList to {}
    tell application "Aperture"
      activate
              set imageSel to (the selection)
              if imageSel is {} then
                        error "Select images."
              else
                        repeat until (count of newList) = (count of imageSel)
                                  set randomPick to random number from 1 to (count of imageSel)
                                  if randomPick is not in newList then set newList's end to randomPick
                        end repeat
                        repeat with i from 1 to count of newList
                                  tell item i of imageSel to make new custom tag with properties {name:"Random", value:item i of newList}
                        end repeat
              end if
    end tell
    Takes a selection and assigns random numbers to each image in the selection,
    Creates a custom tag Random and populates it with numbers. If you add the custom field Random to the list view metadata parameters you can sort on it and then switch back to icon view and the images will remain in the random order.
    You have to be careful if you change the sort order of course the randomness will be gone and you will need to go back to list view to re-establish it.

  • HOW DO I KEEP AN ARRAYLIST IN RANDOM ORDER AFTER EXITING THE SUB ROUTINE CONTAINING IT

    PLEASE HELP!I am trying to go from VB4 which I loved to VB2010 which I find somewhat more challenging. I’ve searched the web for help and have adapted the following to my project. This code does
    rotate randomly through every card in the deck and displays unique cards until all have been drawn. BUT I want to draw one card
    only from the first “hat” of Boy’s names; then draw the second card from the second “hat” of Girl’s names and repeat this process until all cards in both decks have been drawn. How do I get the TextBox (OR any
    MsgBox) to display JUST ONE unique random card at a time so I can exit that deck and go to the next deck?
    On my form, I have two TextBoxes (to display the names (as drawn), two buttons (to re-load each deck once exhausted) and one command (&End)control (to end the process). I created two ArraysLists
    (to hold the Boys names and Girls names separately) and two ArrayLists to hold the cards for the random decks when created in code.
    I can
    NOT get this code to draw random UNIQUE names once I exit the deck. I have tried to ReDim the deck; randomly pull a card from the second (temp) deck, etc
    NOTHING seems to work.
    WHY does my deck lose randomness once I exit it?
    How can I fix it? I don’t understand this. Below is the code for the "hat" with the 10 girl's names.
    Also, when I don't loop through all the cards, I usually get "An Out of Index exception was not handled" error. Hope someone can help me with this problem. It seems like this should
    be easy BUT I'm baffled. Thank you for any help.
    Imports System.Collections.Generic
    Public Class Form1
    Dim Count As Integer
    Dim Rcard As New ArrayList
    Dim Dcard As New ArrayList
    Dim NewRDeck As New ArrayList
    Dim NewDDeck As New ArrayList
    Dim temp_Rnum As Integer
    Dim temp_Dnum As Integer
    Dim MyRand As New Random()
    Public Sub Rcards_Click(sender As Object, e As System.EventArgs) Handles Rcards.Click
    While Rcard.Count > 0
    Dim temp_Rnum As Integer = Int(MyRand.Next(Rcard.Count))
    NewRDeck(temp_Rnum) = Rcard(temp_Rnum)
    Rem Check that the ArrayLists work correctly and display properly
    MsgBox(Rcard(temp_Rnum), , "New random card selected is: ")
    Console.WriteLine(Rcard(temp_Rnum))
    Rcard.Text = (Rcard(temp_Rnum))
    REM Now remove the Rcard with the random number generated so it can't be drawn again
    Rcard.RemoveAt(temp_Rnum)
    End While
    REM When all 10 cards have been picked, alert player to re-load deck if desired.
    MsgBox("No new cards left in deck; please Re-Load the cards. Thank you.")
    EndSub
    End Class

    Hi Acamar,
    Thank you for such a fast response. Sorry if my text wasn't clear. I'm really struggling with creating unique random elements in Collections in VB2010 and feel I understand ArrayLists better than some of the other Collection types.The code works perfectly
    and generates unique random cards until the original deck is exhausted. Then it prompts the user to re-load the original deck so it can be reused if needed. But I need to draw one card only and exit the deck. Then when I click on the TextBox again, I want
    that deck to be in the same random order - just minus any cards I have already drawn and thrown away.  Thanks again for your help.
    Here's the rest of the code for just the girl's "hats" of names, if it helps:
    Private Sub btnShuffleRCards_Click(sender
    As System.Object, e
    As System.EventArgs)
    Handles btnShuffleRCards.Click
    Dim j As
    Integer
    For j = 1 To 10
    NewRDeck.Add(j)
    Next j
    Randomize()
    REM Create original Deck with names for the girls.
    Rcard.Add("1 HELEN”)
    Rcard.Add("2 OLIVIA")
    Rcard.Add("3 <st1:city w:st="on"><st1:place w:st="on">ALICE</st1:place></st1:city>")
    Rcard.Add("4 VALERIE")
    Rcard.Add("5 DONNA")
    Rcard.Add("6 ZELDA")
    Rcard.Add("7 MARGARIE")
    Rcard.Add("8 <st1:city w:st="on"><st1:place w:st="on">NANCY</st1:place></st1:city>")
    Rcard.Add("9 WANDA")
    Rcard.Add("10 IRENE")
    End Sub

  • I have 160gb of music on my Classic, 6th Gen (I think) I've just bought it. Is it possible for it to play my songs in a random order, one or two from different albums?

    I have 160gb of music on my Classic, 6th Gen (I think) I've just bought it. Is it possible for it to play my songs in a random order, one or two from different albums?

    To add to what Stonerock has mentioned, you can either create Playlists in your iTunes Library, containing exactly what you want, and then Sync them to your iPod, or you can use the iPod Classic's On-The-Go feature.
    Reading between the lines, I'm going to assume for now that you want to be able to create your preferred listening list while "out and about" - so not near your iTunes library. (You have posted in iPod Classic, after all.) You can do this with the On-The-Go Playlist.
    Look in the Playlists menu on the iPod. It probably contains the Recently Added, Recently Played and other pre-made Playlists that you see in your iTunes Library. At the bottom of the Playlists list, is the On-The-Go showing 0 Songs. Scroll down to it and press the Select (centre) button. The screen will give you instruction on adding songs to the On-The-Go Playlist.
    Basically, if you press-and-hold the Select (centre) button, while highlighting a song, the song title will blink as it is added to the On-The-Go Playlist. Try it, then go back to Playlists/On-The-Go and notice that it will now say 1 Song. (Note, you cannot add a "now playing" song to the On-The-Go Playlist.) Repeat this for every song you want to have in the list. You can also look in the Albums menu, highlight the album title and press-and-hold that to add the complete album to your On-The-Go Playlists with one press. So if you add the two albums to your On-The-Go Playlist, you can then listen to just those two albums.
    To shuffle the songs, turn on Shuffle on your iPod. Either, go into Settings/Shuffle and press the Select button to toggle between Off/Songs/Albums, or on the Now Playing screen, press the Select button three times to reach the Shuffle option, where you use the scroll wheel to move between Off/Songs/Albums, press the Select button to activate it.
    Having added songs to the On-The-Go Playlist, go into it and notice the list of songs and options to Save Playlist (New Playlist 1) or Clear Playlist. If you use Sync to manage your iPod (and that really is the best way by the way), the next Sync will transfer any unsaved On-The-Go and any New Playlist Xs that you have, back to your iTunes Library. You can even remove any song from the current On-The-Go Playlist by highlighting it (in the On-The-Go, obviously) and press-and-holding the Select button.
    If you need assistance in creating a Playlist in your iTunes Library, please ask.

  • Random order by in SQL!

    11g
    Hi There,
      I had posted this query in the Application express forum, but I guess it really should have been posted in this forum, since its more of a sql question. Apologies if this is against the forum rules.
      We have a pie chart in Application Express which has select like
    select null, '0-10' Days , count(*) from table
    union
    select null, '11-20' Days, count(*) from table
    union
    select null, '21-30' Days, count(*) from table
    union
    select null, '>30' Days, count(*) from table
    The 3d pie chart was showing the slices is the correct order 0-10, 11-20, 21-30, >30 but now shows it in random order.
    Unfortunately, the charts in Apex have a restriction as far as the select statement is concerned, it should just have three values in the select statement, the first is a link (can be null), the second can be any column_name or description and the third a value like count, sum etc. Now, the above query is to get the count of sales in the mentioned number of days and so what is happening is that it is taking the values as character sorting and I think randomly sorting in the apex chart. Now, this works fine in SQL! So was wondering if anyone has any suggestions on how to maybe force the sorting on the second column (0-10, 11-20 etc). If I take those values as 010, 1120, 2130 3000, something like that(basically a number) it seems to work fine, but then those show up as labels on the chart which is not correct.
    Any suggestions on how to get the order by working. I suspect since the Days column in the select is a Character column this issue is occurring, however, with the restrictions in the number of select items we can have in the Apex charts, was wondering how do you get the order by working?
    Thanks,
    Ryan

    you would have to add an explicit order column that maps the string to its position in the result: that could be an id:
    group_name|group_id
    > 60      | 4
    11-30     | 2
    0-10      | 1
    31-60     | 3
    Regards
    Martin
    P.S.: and you could add the information via: case when group_name = ... then 1 end group_id

  • Random order of adverts in inDesign document

    Hi!
    I have a monthly publication with about 18 pages of adverts with two to 6 adverts on each page. Every month I have to randomly change the order to make sure sometimes people are towards the fropnt, sometimes near the back. Is there any plugin or way to automate the process and randomly change the order of the advert groups?
    Cheers,
    Matt

    Put the photos in an album and manually sort them in as a random order as you can. The in your iDVD project, create a slideshow, enter the slideshow mode and under the Media pane, select that album and drag it into the sideshow window at the left. The order will be the same that you created in the album.
    Or, if you click on the album and use the Share->Send to iDVD the order will be the same as the album.
    Do you Twango?
    TIP: For insurance against the iPhoto database corruption that many users have experienced I recommend making a backup copy of the Library6.iPhoto database file and keep it current. If problems crop up where iPhoto suddenly can't see any photos or thinks there are no photos in the library, replacing the working Library6.iPhoto file with the backup will often get the library back. By keeping it current I mean backup after each import and/or any serious editing or work on books, slideshows, calendars, cards, etc. That insures that if a problem pops up and you do need to replace the database file, you'll retain all those efforts. It doesn't take long to make the backup and it's good insurance.
    I've written an Automator workflow application (requires Tiger), iPhoto dB File Backup, that will copy the selected Library6.iPhoto file from your iPhoto Library folder to the Pictures folder, replacing any previous version of it. It's compatible with iPhoto 08 libraries. You can download it at Toad's Cellar. Be sure to read the Read Me pdf file.
    Message was edited by: Old Toad

  • Releasing tasks in random order

    Hello everyone.
    Sorry as I dont know which category to put this question to.
    I have released a couple of tasks (under same transport request) in random order.
    All tasks have almost the same objects that we work on.
    Please tell me what all things can now go wrong in Test Server so i should be prepared for that.
    And also, how to set those things right.
    Thanks

    Hi,
    Though there are different tasks under the same request, and released in different order, but released all the tasks.
    So I don't think you will face major issues in the test system.
    The issues could be,
    1. lets say if you have added one selection screen field, may be it will not get display in the selection screen of the test system.
    For this, you need to go to the SE51 and select the program and screen number as 1000, just click on active.
    2. In a similar way for the screens added or even the program may need manual active in the test system.
    Regards,
    Santhosh.

  • Batch Rename---in Random Order

    Is it possible to batch rename a set of files in a random order? 
    Making a slideshow of a number of events, but I don't want them in the order shot.  I can manually rename and move them, or I could sort by some other order than by name or date, such as file size, I guess, but those options haven't randomized the collection as well as I would like.
    Just askin'...
    Thanks in advance.

    I’m not great with Scripts, but this might work:
    // adds random five digits numbers at the beginning of jpgs’ filenames in a folder;
    // use it at your own risk;
    var theFolder = Folder.selectDialog ("select folder that contains the files to be renamed");
    // for renaming other files than jpgs change the term in the brackets accordingly;
    var theFiles = theFolder.getFiles ("*.jpg");
    for (var m = 0; m < theFiles.length; m++) {
    var theRandomNumber = String(Math.random()).slice(3,8);
    File(theFiles[m]).rename(theRandomNumber + "_" + (theFiles[m]).name)
    One can copy the text into a new file in ExtendScript Toolkit (which should be part of Photoshop’s installation) and start running it by hitting the play-button or save it as a jsx-file into Photoshop’s Presets – Scripts; but it really doesn’t do anything within Photoshop, so it may be better not stored there.
    Anyway it’s probably be best to run it only on a copy of a folder, because getting the numbers back off later on might be bothersome.

  • Zen V Plus plays in random order -- whether I like it or n

    Hi All,
    I searched and read the FAQ but couldn't get an answer that addresses this issue:
    I've put my music on my new Zen V Plus (which I absolutely _love_!) and organized the songs into playlists. When I select a playlist and start it at the first song, however, the order of the songs that follow from there are *completely* random. If I go back and start again, it randomizes the playlist in a different -- random -- order. I've looked through all of the menus and can't find a "random" or "shuffle" setting to turn off. Is this normal? Am I missing some trick?
    Thanks in advance,
    Mark

    Romerica --
    Thanks for your speedy reply! I looked on the Main Menu and there was no "Play Mode" listed. However, having but recently learned about the "Configure Menu" option (under System/Player Settings for those having this same issue), I went in and discovered that the "Play Mode" was un-checked. I checked it and went back the the Main and voila! "Play Mode" was now listed and I could set it back to Normal. Problem solved! Multo, multo grazie!
    Regards,
    Mark

  • Scene Selection out of order...

    I made a movie in FInal Cut Pro and set up Scene Markers. They split up into scenes in iDVD, however the selection is out of order. I'm using 'Reflection White' theme. What happens is when you are selecting through the scenes on the menu it doesn't go in order. Starts with the first one then goes to the bottom, then back up to the top, then to the bottom. Is there anyway to change the order that the DVD will select which next?

    Just catching up with this thread as I have the same problem -- scene selection does not go in the order of the chapters (12) made in FCP and exported as a QT movie. It DOES work on DVD player, but not work on stand alone DVD players (I have 2) through a TV set. And, yes, I tried free positioning to move the scenes around to conform with the pattern iDVD seemed to want but that didn't help either. The pattern of selection seems random, every time I press on the remote it might go: scene 1, scene 4, next page arrow, scene 2, scene 1 and so on. And it seems to differ from one burned DVD to another.
    HELP! I've been trying to solve this problem for three days.
    Thank you.

  • IPhone Podcasts sorted correctly but playing in random order

    I have iTunes 9 and iPhone 3.1. I have read the discussion of people having trouble getting smart playlists of podcasts to sync in the same order as in iTunes. I am not having this problem. I have a smart playlist with podcasts in it and when I sync it with my iPhone and go to the playlist all the podcasts are appearing in the correct order. My problem is when I play them it plays them in a random order (as if shuffle is turned on). I can't see any option to turn shuffle off (if that is in fact what is causing this) or whether this is part of the same problem others are experiencing. I know in iPhone 3.0 when playing a podcast there was a little icon at the top near the 2x and repeat icon that enabled you to turn shuffle on and off but this doesn't appear for me anymore.

    Don't use search to display then play items. Just use it to find them.
    iTunes menu View -> Show column browser.
    Select an artist/Album and press Play.

  • Selector.selectedKeys() random ordering vs. fairness

    All Sun's selector implementations are based on SelectorImpl, which keeps selectedKeys in a classic HashSet with a random order of elements.
    Now, suppose I insist on processing the incoming requests in the exact order as they were received, to ensure fairness. The classic mechanism for ensuring fairness are threads, but this a single-thread solution, and even with threads, it would be more fair to dispatch firstly-received requests first.
    So far the only solution seems to be a dirty (should I say dodgy) replace (via reflection) of the aforementioned HashSet with a LinkedHashSet. (tested on Linux/epoll, works)
    If you know of any other solution please let me know.

    Hi, thanks for replying to both of my comments. (the other thread: http://forum.java.sun.com/thread.jspa?threadID=407203&tstart=0 )
    These two issues are correlated so I will sum it up here, as the other thread is old and in a wrong forum.
    I'm getting the following results:
    1. only a single OP_ACCEPT is signalled in any given select() operation
    2. OP_READs are grouped to a single select(), no matter what time intervals they came in
    Tested on Windows (sun.nio.ch.WindowsSelectorImpl) and Linux (sun.nio.ch.EPollSelectorImpl).
    The accepts are fired inside of 100ms (linux) and 50ms (windows). The reads are split into 3 groups separated by 5 second wait.
    I'm attaching my test program. The two tests are separated and must be manually switched on.
    import java.net.InetSocketAddress;
    import java.net.Socket;
    import java.nio.ByteBuffer;
    import java.nio.channels.SelectionKey;
    import java.nio.channels.Selector;
    import java.nio.channels.ServerSocketChannel;
    import java.nio.channels.SocketChannel;
    import java.util.Iterator;
    public class test2 {
         public static void main(String[] args) throws Exception {
              server server = new server();
              server.bind();
              int test = 1;
              p("running test " + test);
              if(test == 1) { //test the partitioning of read events into more select() operations
                   client cc[] = new client[30];
                   for(int i = 0; i < cc.length; i++) {
                        cc[i] = new client("" + i);
                        cc.connect_to_server();
                   while(server.process_a_single_loop()); //process all the accepts
                   for(int i = 0; i < cc.length; i++) { //send requests in 3 groups separated by 2 waits
                        cc[i].send_data_to_server("hello");
                        if(i == 9 || i == 19) {
                             p("waiting 5 sec");
                             Thread.sleep(5000L);
                   while(server.process_a_single_loop()); //now process the reads
                   p("done");
              if(test == 2) { //test the grouping of more accept events into a single select() operation
                   connect_thread tt[] = new connect_thread[30];
                   client cc[] = new client[30];
                   for(int i = 0; i < cc.length; i++) {
                        cc[i] = new client("" + i); //create new clients
                        tt[i] = new connect_thread(cc[i]); //create connector threads
                   //now quick-start the threads
                   long max = 0L, start = System.currentTimeMillis();
                   for(int i = 0; i < tt.length; i++)
                        tt[i].start();
                   Thread.sleep(1000L); //let the dust settle
                   for(int i = 0; i < tt.length; i++) { //gather client connect time statistics
                        if(max < tt[i].finished)
                             max = tt[i].finished;
                   p("all connections happened inside of " + (max - start) + " ms");
                   while(server.process_a_single_loop()); //now process the accepts
                   p("done");
              server.unbind();
         static class connect_thread extends Thread {
              client c;
              long finished;
              connect_thread(client c) {
                   this.c = c;
              public void run() {
                   try {
                        c.connect_to_server();
                        finished = System.currentTimeMillis();
                   catch(Exception e) {
                        e.printStackTrace();
         static void p(Object o) {
              System.out.println(o);
         static class server {
              ServerSocketChannel server_chan;
              Selector server_selector;
              int loop;
              void bind() throws Exception {
                   server_chan = ServerSocketChannel.open();
                   server_selector = Selector.open();
                   server_chan.socket().bind(new InetSocketAddress (8401));
                   server_chan.configureBlocking(false);
                   server_chan.register(server_selector, SelectionKey.OP_ACCEPT);
                   p("Used selector implementation: " + server_selector.getClass().getName());
              boolean process_a_single_loop() throws Exception {
                   boolean anything_done = false;
                   loop++;
                   p("server - processing loop " + loop);
                   server_selector.selectNow();
                   Iterator<SelectionKey> it = server_selector.selectedKeys().iterator();
                   while(it.hasNext()) {
                        anything_done = true;
                        SelectionKey key = it.next();
                        if(key.isAcceptable()) {
                             ServerSocketChannel server = (ServerSocketChannel) key.channel();
                             SocketChannel channel = server.accept();
                             channel.configureBlocking(false);
                             channel.register(server_selector, SelectionKey.OP_READ, channel);
                             p("server - accepted a new connection");
                        if(key.isReadable()) {
                             anything_done = true;
                             SocketChannel channel = (SocketChannel) key.attachment();
                             ByteBuffer bb = ByteBuffer.wrap(new byte[10000]);
                             channel.read(bb);
                             bb.flip();
                             String s = new String(bb.array(), bb.position(), bb.limit() - bb.position(), "UTF-16");
                             p("server - received data: " + s);
                        it.remove();
                   return anything_done;
              void unbind() throws Exception {
                   server_chan.close();
         static class client {
              String id;
              Socket socket;
              client(String id) throws Exception {
                   this.id = id;
              void connect_to_server() throws Exception {
                   socket = new Socket();
                   //s.setTcpNoDelay(true);
                   socket.connect(new InetSocketAddress("localhost", 8401));
              void send_data_to_server(String data) throws Exception {
                   String buf = "hello from " + s() + ": " + data; // + "\n";
                   socket.getOutputStream().write(buf.getBytes("UTF-16"));
              String s() {
                   return "client[" + id + "]";
    I think I can solve this "unfairness" problem by having a dedicated thread constantly transferring any new events from the selector to my own queue - the select() would be called frequently enough to get the events properly ordered.

  • Playlist shuffles and plays in random order

    My new iPhone 3Gs is driving me nuts when I'm trying to listen to a playlist I created and loaded on my computer. The iPhone plays all of the songs on my playlists in random order. I have the "shake to shuffle" mode off and "shuffle" is not on. I even check to see if the "shuffle" was on in iTunes and it is not. What is the deal? Anybody else having this problem?

    From the Now Playing screen, tap the album cover to see the additional song controls. Makee sure the shuffle symbol on the right side under the scrubber bar is selected to "white".
    See this for a picture: http://www.apple.com/iphone/how-to/#ipod.additional-song-controls

  • Files open/copy in random order

    I often work with multiple numbered files that I need to keep in order however I find when opening them, or copying them either locally or across a network they will open/copy in a random order.
    For instance, if I have 12 single page pdf files I'd like to open, selecting them all and double clicking on them will give me a jumbled mess in Adobe Acrobat (preview opens them in numerical order though), If I drag them into my automated renaming tool (R name) they come in out of order, or when copying them to another server across our network then arrive in a random order.
    We have this issue on several computer in several locations all running OS X 10.4.11, however one computer seems to copy/open files in the correct order. Is there a setting somewhere or terminal command I can run to get OS X to handle files the way I want, what am I missing?

    There are three workarounds you can use for this annoying issue:
    1. Use column view instead of list view.
    2. Select your files in the open dialog box instead.
    3. Open files using Adobe Bridge Instead.
    We just wrote this up as a tip in our weekly tips blog:
    http://www.creativetechs.com/iq/avoidthe_finders_odd_sort_when_openingfiles.html

  • Create random order slideshow and burn to dvd

    I am trying to create a random order slideshow and burn it to a dvd playable on a dvd player. I tried creating the slideshow in iphoto using the album mode, and was successful in creating the slideshow, but cannot save, export or burn. Would appreciate any help.

    Thanks for your help!
    I am trying to make a slide show of 900+ photos. I moved the photos from a CD into iPhoto. Originally I tried Magic iDVD, dropped the photos from the Event zone into the drop zones in Magic iDVD, chose a theme and previewed. The slides were shuffled from the beginning, and at first I thought that some of the themes allowed the shuffling of the slides as an effect. However, I did notice that the slides remained in the same order regardless of the theme chosen, but wasn't sure why this was the case. I then made the mistake of trying to eliminate a few of the slides and divide the slides more evenly between the two drop zones. I went back to the Event, opened the folder and selected the photos to be included and moved them to a new folder. From that point on the "shuffle" of the photos was gone and the photos appeared in the order in which they were taken. I spent several hours of trial and error trying to reinstate the shuffle, called Apple, talked with various Apple help and more expert users and finally ended up seeking help from the discussion boards where I found the post explaining how to create the shuffled slideshow in the Albums area of iPhoto . This is exactly what I am looking for--shuffled photos and random transitions! Unfortunately, it seems as though you can only view this slideshow from the computer. Now I am looking for another way to do the same thing. I am new to Apple, and trial and error is extremely time consuming and in this case not very productive. If there is a software program which will create a random shuffle (either Mac or Win) I can always create the shuffle and then import the photos back into the Events folder and create the DVD. Any help/ideas for a successful completion of this project are welcome! Thanks.

Maybe you are looking for