Refine a query to return only one day in the current week

Hello again,

Sorry, I thought I could work this given my previous help on the forum but I can't.

What I do now is to look at the date ranges of records and display which of them are active on a given day of the current week. So for the week beginning June 27, 2011, a Monday, I need to see the records that are present on that day. The same thing on Tuesday, sea, game, Fri.

Any ideas?


Kind regards

Steve Welch

Hi Steve,.
No doubt there is a way more elegant to do, but based on my previous post example...

SELECT TO_CHAR (begin_date, 'DD-Mon-YYYY HH24:MI:SS') AS begin_date,
TO_CHAR (end_date, 'DD-Mon-YYYY HH24:MI:SS') AS end_date,
CASE WHEN TRUNC(begin_date) NEXT_DAY (TRUNC (SYSDATE) - 1, 'Sat') - 7 THEN 'X' END AS "Sun",
CASE WHEN TRUNC(begin_date) NEXT_DAY (TRUNC (SYSDATE) - 1, 'Sat') - 6 THEN 'X' END AS "Mon",
CASE WHEN TRUNC(begin_date) NEXT_DAY (TRUNC (SYSDATE) - 1, 'Sat') - 5 THEN 'X' END AS "Tue",
CASE WHEN TRUNC(begin_date) NEXT_DAY (TRUNC (SYSDATE) - 1, 'Sat') - 4 THEN 'X' END AS "Wed",
CASE WHEN TRUNC(begin_date) NEXT_DAY (TRUNC (SYSDATE) - 1, 'Sat') - 3 THEN 'X' END AS "Thu",
CASE WHEN TRUNC(begin_date) NEXT_DAY (TRUNC (SYSDATE) - 1, 'Sat') - 2 THEN 'X' END AS "Fri",
CASE WHEN TRUNC(begin_date) NEXT_DAY (TRUNC (SYSDATE) - 1, 'Sat') -1 THEN 'X' END AS "Sat"
FROM mydates
WHERE TRUNC (begin_date) < NEXT_DAY (TRUNC (SYSDATE) - 1, 'Sat') + 1
AND TRUNC (end_date) > NEXT_DAY (TRUNC (SYSDATE) - 1, 'Sat') - 7
ORDER BY begin_date 

would give

BEGIN_DATE end_date Mon Mar sea game Fri Sat Sun
June 15, 2011 06:48:29 June 25, 2011 06:48:29 X X X X X X X
June 25, 2011 06:47:57 July 5, 2011 06:47:57 X

See you soon,.
Rob

Published by: Robert Chalton on June 25, 2011 10:31

Tags: Database

Similar Questions

  • Help with the query to select only one record from the result set in double

    Hello

    Please help with the query. Version of Oracle database we use is 10g R2.

    I have a vision that is duplicated IDS, but they are used across the different functions. See below examples of data. Please help me with a query to select only one record (based on ID regardless of the area) from the bottom of the result set of duplicate records. For what is the point of view is there unique records, given the combination of the fields ID, Org, DF, dry, Sub-Sec

    ID
    Org
    DF
    Sec Sub-Sec

    (163)CQCPDMCPDMHD(163)PCENGENGENG(163)CQASICASICIS8888TSTACTACTAC(163)TSHEHESW6789CQINFOINFOFOS6789PCSECSYSSECSYSINFO16789TSSECSYSSECSYSINFO29009PCBMSBMSBMS1

    My result set must eliminate the duplicate identifiers regardless of whoever we choose of the result set. (I mean without distinction Org, DF, s, Sub-s). My expected result set should be.

    ID
    DSB

    DF
    SEC
    Sub-Sec
    (163)CQCPDMCPDMHD8888TSTACTACTAC6789CQINFOINFOFOS9009PCBMSBMSBMS1


    Thank you

    Orton

    Hello

    This sounds like a job for ROW_NUMBER:

    WITH got_r_num AS

    (

    SELECT id, DSB, df, s, sub_sec org

    ROW_NUMBER () OVER (PARTITION BY ID.

    ORDER BY org

    ) AS r_num

    OF view_x

    )

    SELECT id, DSB, df, sub_sec s,

    OF got_r_num

    WHERE r_num = 1

    ;

    He is a Top - N query example, where you choose the elements of N (N = 1 in this case) from the top of an ordered list.

    I hope that answers your question.
    If not, post a small example of data (CREATE TABLE and INSERT, only relevant columns instructions) to your sample data and the results desired from these data.  (I know that you said that you were a view selection.  Just for this thread, pretending it is a picture and post simple CREATE TABLE and INSERT statements to simulate your point of view).
    Point where the above query is to produce erroneous results, and explain, using specific examples, how you get the right results from data provided in these places.  (I didn't quite understand the explanation above.  I don't know why you want to

    ID ORG DF DRY SUB_SEC

    --      ---     --      ---     -------

    1234 CQ DPRK DPRK HD

    and is not

    1234 IS CQ ASIC, ASIC

    or

    TS 1234 IT IT SW

    or

    1234 CQ ASIC ASIC HD

    )
    If you change the query at all, post your modified version.
    Always say what version of Oracle you are using (for example, 11.2.0.2.0).

    See the FAQ forum: https://forums.oracle.com/message/9362002

  • Refine a query to display only the entries for the current week

    Hello.

    Anyone know how to change a query to display only those records that have dates of the current week? Records have a start date and an end date, so the query should recognize that the entry may be valid for more than one week?

    Kind regards

    swelch

    Hi Steve,.

    I just created a dataset that contained the periods before, during and after the current week - on the assumption that if any day of a range (start/end) falls within the current week so it is included.

    In my example this is 'today', June 25, 2011, and a week is defined as Sun - Sat. So my week of 'course' is u 19 June 2011 / I June 25, 2011.

    A line any with a start date before or during my 'current' week and an end date that is after or during my "current" week, i.e. no matter what date in its range included in the 'in progress' week will appear.

    See you soon,.
    Rob

  • Need help to write a MySQL query that returns only the peer matching records

    Because I don't know how to explain it easily, I use the table below as an example.

    I want to create a MySQL query that returns only the records that match counterparts where 'col1' = 'ABC '.

    Notice the ' ABC / GHI' record does not have a Counter-match ' GHI / ABC' record. This record must not be returned because there is no Counter-Party correspondent. With this table, the ' ABC / GHI' record should be the one returned in the query.

    How can I create a query that will do it?


    ID | col1 | col2
    --------------------
    1. ABC | DEF
    2. DEF | ABC
    3. ABC | IGS
    4. DEF | IGS
    5. IGS | DEF


    * Please let me know if you have no idea of what I'm trying to explain.

    I wanted to just the results where col1 = ABC, but I already got the answer I needed on another forum. Thank you anyway.

    SELECT a.col1,
    a.col2
    FROM table_name AS a
    LEFT OUTER
    Table_name JOIN b
    ON b.col1 = a.col2
    AND a.col1 = b.col2
    WHERE b.col1 IS NOT NULL AND a.col1 = 'ABC '.

  • Hard drive inexplicably doubled from one day to the next

    My hard drive inexplicably doubled from one day to the next.  I now have only 3 GB free.  I did disk cleaning, defrags, uninstalls, deleted files (just 23 GB of personal files, music, etc. 99 GB drive), etc.  I downloaded TreeSize and see what the size of my files are, but don't know what is normal.  Common sense tells me that clearly something has changed the last time I used my computer to create this problem, but the only change I made was moving my personal files in my user folder to a Public folder, and then in my computer with my other laptop's network.  I checked three times, and my previous user folder files have definitely missing.  Could a bunch of file system are duplicated or something like that?  I know that I cannot delete them, but is it possible to clean them safely?

    To clean all the files on the computer

    1. Click to open Disk Cleanup.

    2. In the drives list, click the drive you want to clean, and then click OK.

    3. In the Disk Cleanup dialog box, click on clean up system files. If you are prompted for an administrator password or a confirmation, type the password or provide confirmation.

    4. In the disk cleanup: drive selection dialog box, select the drive you want to clean, and then click OK.

    5. In the dialog box disk cleanup, on the Disk Cleanup tab, select the check boxes for the types of files that you want to remove, and then click OK.

    6. In the message that appears, click on delete files.

      The other Options tab is available when you choose to clean up the files of all users on the computer. This tab includes two additional ways to free disk space even more:

      • Programs and features. This option opens programs and features in Control Panel, where you can uninstall programs you no longer use. The column size in programs and features shows how much disk space each program uses.

      • System Restore and shadow copies. With this option, you can remove all but the most recent point on the restore disc.

        Use system restore to return your system files to an earlier point in time, restore points. If your computer is running normally, you can save disk space by removing the previous restore points.

        In some editions of Windows 7, restore points can include previous versions of files, called the shots and backup images created with Windows complete PC Backup. These files and images will also be deleted. For more information about system restore, see what is system restore?

  • 'Notes' disappeared from one day to the next

    my "notes" have disappeared from one day to the next. Last accessed last night. Saved on phone appearing with that few, I changed last night. The format has also changed and he no arrow at upper LH has. Anyone who has experienced similar?

    Hello

    If use you iCloud for synchronize your Notes, tap Settings > iCloud then make sure that Notes is toggled ON.

  • Why do you have my emoticons change from one day to the next and how can I get the 'old'?

    The choice of emoticons changed from one day to the next. I would like to have the 'old'. Why Gmail does not send a msg Heads Up? Thank you.

    Hello

    This does not sound like a Firefox problem, but a change that was made to Google for their e-mail service. I recommend that get you in touch with them through the channels of Gmail support and they may be able to help.

  • New FF 32.0.2 break from one day to the next. Full disclosure - Cookie Clicker

    I use FF for many things, often many tabs, etc. I picked up clicker cookie a month or two ago. I always left CC running from one day to the next day without any problem until FF update to version 32.0.2 and now I'm back in the morning to find that it is broken down.

    More recent reports of incidents:

    BP-977c17bd-f1fe-4A8A-98e3-773682140919 19/09/14 07:21
    BP-256c08cf-0725-4200-bA1a-fe2b62140918 18/09/14 07:55

    I use very little add on, same theme, that I had for many years, nothing has changed other than the version of FF I know.

    Any help is appreciated!

    Full Disclaimer: Yes, I know that the perils of the performance of my computer all night. Since I always did before upgrading the version of FF, I fear that this time with which these accidents started after this upgrade. Thank you!!!

    Next steps that I took:

    1 recorded progress, tab reloaded.
    2. right click on the page and go to "display information page.
    2.a. Under support, scrolls to find ads (usually flash .swf) and blocked images from these sites.
    2.b. 1 - 2A to repeat several times
    2.c. According to the news page-> permissions, blocked Adobe Flash for just this site.

    The performance so far is upward. We'll see how he holds up the night.

  • I need to create a table of contents in iPages but I want only one word for the title, not the line of holes. Or, how can I change the contents of the table? Thank you!

    I need to create a table of contents in iPages but I want only one word for the title, not the line of holes. Or, how can I change the contents of the table? Thank you!

    Yes, you can have a one word title, by assigning a paragraph style title to this one word. No, you cannot change the text in a Table of contents, but you can change paragraph style font attributes (line) and add for example, a head of points between the types of OCD paragraph and page numbers. No part of the table of contents will not provide hyperlinks in exported PDF documents.

    When you look up in the menu bar, you can see the word iPages, or simply Pages. There is no product of iPages.

  • WiFi adapter has gone from one day to the next

    HI - can someone help me understand why the wifi adapter might have disappeared since the device from one day to the next Manager? And how do I get it back?

    Thank you very much

    P

    Hi P_1

    One of the reasons why a device disappear are simple a hardware malfunction.
    It would be very interesting to know what model of laptop you have and what card WLan disappeared.
    But generally if the Wlan chip isn t listed in Device Manager, and if there is no yellow or peripheral exclamation points strangers, then everything looks like a hardware failure.

  • Once I reset my battery CMOS from one day to the next. I tried to install my recovery disk this morning and can't get it done

    Once I reset my battery CMOS from one day to the next.  I tried to install my recovery disk this morning and can't get it done.  I kept receiving an error of 100.
    Don't know what to do.
    Are there out there can HELP?

    Please, I beg you!

    Thank you

    Hello

    Would you please ask the same questions more then once in these Forums.

    What you're doing is confusing in these Forums, as nobody else knows what advice are envisaged for you in other responses.

    Other questions, it seems you have an HP computer.

    Here is the information of HP for Vista from recovery to factory settings:

    "Recover Windows Vista operating system using HP Recovery"

    http://h10025.www1.HP.com/ewfrf/wc/document?DocName=c00809678&LC=en&DLC=en&cc=us&product=18703

    Restore the PC to its original state with the recovery discs

    If the PC cannot access the Windows desktop, and the Recovery Manager cannot be started by selecting the f11 at startup key, you can use either the recovery disc custom that you created, or you can order a recovery CD to replace HP, to boot the PC and restore the hard drive to its original operating state.
    NOTE: perform the recovery process by using the custom recovery disk you created can take less than an hour, whilst using the replacement disks ordered directly from HP can take four to six hours and includes several reboots.
    If the HP Recovery Disk Manager can access the hard drive, it will attempt to repair the recovery partition. If successful, a prompt to continue execution of the recovery using the Recovery Disk Manager.
    Use the recovery discs to restore the PC by following the steps below.
    1. Insert the recovery disc into the optical disc drive and start the computer.
      If the computer is running, insert the reinstallation disc and immediately click on Start and select restart to force the computer to boot from the recovery disc.
    2. When prompted, Press any key to boot from the CD or DVD, press any key on the keyboard.
    3. Leave the recovery disk boot and load the files required, while the Microsoft loading screen appears. It may take several minutes to load the required files.
    4. When the HP Recovery Manager window appears, click Advanced options , System Recovery , and then click Next to open the Recovery Manager.
    5. etc.

    If you are having problems using the HP recovery process, you will need to contact HP, because this is Recovery process HP, not Microsoft.

    Details of HP:

    http://WWW8.HP.com/us/en/contact-HP/contact.html

    You can also try the Forums from the HP Support:

    http://h30434.www3.HP.com/

    See you soon.

  • LOV cascading if I don't have only one table with the customer name and the name of the product in the ADF.

    Hi Please help me how to use cascade, if I don't have only one table with the customer name and the name of the product in the ADF... I use Jdeveloper 11.1.

    For the client, I used customer VO with client list to fill but to populate the product that I use bind variable PrODUCT_NAME select distinct from TABLE where client_name =: bindCustomer

    so first of all, I need to set the variable of liaison on behalf of the selected customer.

    Can you please tell me how to set this variable binding in this case.

    After you set the LOV to your product attribute, correspondting VO in the LOV will appear under view accessors.

    Change the accessor of the view, you will see the variable binding. Set its value to the customer field of the parent object.

    Visit this link: https://www.youtube.com/watch?v=nXwL2_RP7AQ

    Kind regards

    Elias.

  • Hi, I have bought LR6 and installed cloud creative ok, but when you go to installation of Lr, it allows only one installation of the trial version, the other options are to buy. I expect that when I pay 129 euros for the LR I can install it easily and not

    I bought LR6 and installed cloud creative ok, but when you go to installation of Lr, it allows only one installation of the trial version, the other options are to buy.

    Serialize Lightroom trial to activate like Lightroom 6 CC

    https://helpx.Adobe.com/Lightroom/KB/serialize-Lightroom-CC-trial-to-activate-as-Lightroom - 6.html

  • How can I change the automatic country setting that is displayed in the payment gateway billing address? There is only one country in the drop-down list, not my current country

    How can I change the automatic country setting that is displayed in the payment gateway billing address? There is only one country in the drop-down list, not my current country

    A few changes/Verify account https://forums.adobe.com/thread/1465499 links that can help

    -html http://helpx.adobe.com/x-productkb/policy-pricing/change-country-associated-with-adobe-id.

  • How can I keep only one instance of the javafx application at the same time?

    Hello
    How can I keep only one instance of the javafx application at the same time?
    Let not the user run the javafx application is running on your PC.

    Hello. This program does what you want. You can probably find a better solution.

    import javafx.application.Application;
    import javafx.event.ActionEvent;
    import javafx.event.EventHandler;
    import javafx.scene.Scene;
    import javafx.scene.control.Button;
    import javafx.scene.layout.StackPane;
    import javafx.stage.Stage;
    
    import java.io.BufferedReader;
    import java.io.File;
    import java.io.FileReader;
    import java.io.FileNotFoundException;
    import java.io.*;
    import java.nio.channels.FileLock;
    import javafx.application.Platform;
    import javafx.stage.WindowEvent;
    
    public class Simpleapp extends Application {
    
        public static void main(String[] args) {
    
            launch(args);
        }
    
        @Override
        public void start(Stage primaryStage) throws Exception {
    
            final File file = new File("flag");
            final RandomAccessFile randomAccessFile = new RandomAccessFile(file, "rw");
            final FileLock fileLock = randomAccessFile.getChannel().tryLock();
    
            System.out.print(fileLock == null);
            if (fileLock == null) {
                Platform.exit();
            }
    
            primaryStage.setTitle("Hello World!");
            Button btn = new Button();
            btn.setText("Say 'Hello World'");
    
            StackPane root = new StackPane();
            root.getChildren().add(btn);
            primaryStage.setScene(new Scene(root, 300, 250));
    
            primaryStage.setOnCloseRequest(new EventHandler() {
    
                @Override
                public void handle(WindowEvent arg0) {
                    try {
                        fileLock.release();
                        randomAccessFile.close();
                        System.out.println("Closing");
                    } catch (Exception ex) {
                        System.out.print(ex.getMessage());
                    }
    
                }
            });
    
            primaryStage.show();
        }
    }
    

Maybe you are looking for

  • SMS over Wi - Fi

    I understand that this could be a problem of carrier, but I wanted to tender hand to see if anyone has the same problem. When I switch to the iPhone 7 more, I stopped to receive SMS over Wi - Fi.  I can send and receive the iMessage and I can send SM

  • Apple TV connection Mac Pro (2009)

    I have a Mac Pro (2009). I wish I could watch pictures and videos on my TV via Apple TV. Is there a way to do this? What equipment or programs do I need? I can connect and watch YouTube on my iPhone through Apple TV. Is there a way I can make it thro

  • Quicken Essentials shows all banks not supported, will do not call into account. Why?

    I tried to update my account directly from my bank this morning, and the application kept crashing when I hit update. I went and re-entered my account information, and it still crashed. Finally, I shot to the top of the list of banks and all banks ar

  • Control disabled but not grey

    Hello. Is it possible to do? Thank you Vasileios.

  • Problem with the installation of an operating system

    Hi, Gays I have hp dv6 7000 with 1 TB drive HARD Toshiba with 32 GB SSD as cache accererator. I tried to install windows 8, but I have trouble finding the drive in to choose in which partition should be installed. Have you had anyone a problem like t