Using to_char in order to extract "WW".

Hello
The other day asked me to write a sql statement that retrieves the number of weeks per year...
with sample as 
  (select yr
    from
     (select 1999+level yr
       from dual
       connect by rownum<level+1
      )
  )   
  select yr, to_char(to_date('30/12'||yr,'dd/mm/rrrr'),'WW') dt
    from sample
The above query returns the data correctly... but when I try:
(the difference is written in "BOLD", I get the same number of weeks for each year - which is obviously not correct)
with sample as 
  (select YR
    from
     (select 1999+level YR
       from DUAL
       connect by rownum<level+1
      )
  )   
  select YR, TO_CHAR(TO_DATE('*31*/12'||YR,'dd/mm/rrrr'),'WW') DT
    from sample
Can someone describe why is this difference...?

Note: I use db 10g v.2
Thank you
SIM

Hi, Sim,

sgalaxy wrote:
Hello
The other day asked me to write a sql statement that retrieves the number of weeks per year...

A the applicant explains exactly what that means.

with sample as (select yrfrom(select 1999+level yrfrom dual connect by rownum

The above query returns the data correctly...

Is this really good? It seems to say that all ordinary years (i.e., the years with only 28 days in February) have 52 weeks, and all this leap years (years where there is a 29 February) have 53 weeks.

but when I try:
(the difference is written in "BOLD", I get the same number of weeks for each year - which is obviously not correct)

Why not? Every year (at least in the Gregorian calendar) have the same number of months. Why every year cannot have the same number of weeks?

with sample as (select YRfrom(select 1999+level YRfrom DUAL connect by rownum

Can someone describe why is this difference...?

To study in detail what Peter said:
WW '01' is always January 1 to January 7.
WW '02' is always on January 8 to January 14.
WW '03' is always on 15 January until 21 January.
...
WW '08' is always from February 19 to February 25.
WW '09' is February 26 March 4 in common years, but in leap years, it is February 26 to March 3.
WW '10' is March 5 March 11 in common years, but in leap years, it is from March 4 to March 10.
...
WW '52' is December 24, but on 30 December in common years, but in leap years, it is December 23 to December 29.
WW '53' is December 31, (only 1 day) in common, but in leap years, it is December 30 and December 31.
It is therefore 31 December always in week '53'. December 30 is in week 52 ' in common years, but in leap years, it is in week 53'. Looking at the week which includes December 30, you get '52' to 3 over 4 years and 53' like clockwork every 4th year (except at the turn of the century most).

According to the definition of "WW" for a week, calendar years always have all 52 weeks (seen 7 days each), plus 1 week defective (having only 1 or 2 days).
A different definition of a 'week' (and year) is the definition of ISO, where all weeks begin on Monday, and all the weeks have 7 days. The ISO year starts the Monday closest to January 1. Using these definitions, most years consist of 52 weeks, but every 5 or 6 years a year ago with 53 weeks.
The display of the query after the last day of several weeks of ISO and watch what week they are in (which is the total number of weeks this year from ISO).

SELECT     TO_CHAR ( TRUNC ( ADD_MONTHS ( DATE '2000-07-01'
                                  , 12 * LEVEL
                         )
                 , 'IYYY'
               ) - 1
          , 'DD-Mon-YYYY   IYYY IW'
          )    AS iso_info
FROM     dual
CONNECT BY     LEVEL     <= 25
;

When I try to understand nested expressions, like the preceding, I find this helps them to read from the inside (i.e., the more deeply nested point) and then work outward.
ADD_MONTHS (DATE "2000-07-01', 12 * LEVEL") is 1 July of some year, which is in the middle of the ISO year.
TRUNC (ADD_MONTHS (DATE "2000-07-01', 12 * LEVEL"), "IYYY") is the first day of a year of ISO.
TRUNC (ADD_MONTHS (DATE "2000-07-01', 12 * LEVEL"), 'IYYY')-1 is the last day of a year of ISO.
The result of the above query is:

ISO_INFO
------------------------
31-Dec-2000   2000 52
30-Dec-2001   2001 52
29-Dec-2002   2002 52
28-Dec-2003   2003 52
02-Jan-2005   2004 53
01-Jan-2006   2005 52
31-Dec-2006   2006 52
30-Dec-2007   2007 52
28-Dec-2008   2008 52
03-Jan-2010   2009 53
02-Jan-2011   2010 52
01-Jan-2012   2011 52
30-Dec-2012   2012 52
29-Dec-2013   2013 52
28-Dec-2014   2014 52
03-Jan-2016   2015 53
01-Jan-2017   2016 52
31-Dec-2017   2017 52
30-Dec-2018   2018 52
29-Dec-2019   2019 52
03-Jan-2021   2020 53
02-Jan-2022   2021 52
01-Jan-2023   2022 52
31-Dec-2023   2023 52
29-Dec-2024   2024 52

There are many other ways to define the 'week' and 'year '.
For example, we could say that all weeks begin on Sunday and I have 7 days a year start the Sunday closest to January 1.
Another example: one could say that all weeks begin on Sunday and I have 7 days and a year beginning the first Sunday after December 31.
In any case, there's how many weeks in a year depends on what your definition of 'week' and 'year '. If you hear the word 'year' out of context, there is a good chance that the speaker refers to the period that begins on 1 January and ends on 31 December. If you hear "week" out of context, there is much less certainty what the speaker means.

Tags: Database

Similar Questions

  • I would use Yuanti SC police for my web development project. However, my developer is not able to use the file .ttc I extracted from the library of fonts, and .ttf, .otf .woff formats not available anywhere on the web.

    I would use Yuanti SC police for my web development project. However, my developer is not able to use the file .ttc I extracted from the library of fonts, and .ttf, .otf .woff formats not available anywhere on the web. Please, let me know how can I use this font for my project.

    Thank you

    Anton

    Unless the site you develop is for the Asian market, I don't know why you want to use that particular font. The Basic, standard and digital alphabet punctuation glyphs has sans serif, Roman characters, but the rest is thousands of Kanji characters. While you can use the font .ttf and .otf and web fonts, it would be very unusual to use one so great. Pages should load quickly and 78 MB, with a value of faces to download for those who have connections slow Internet is not fast.

    I would take a different font without serifs. There are literally thousands who look identical or virtually identical to Yuanti.

    131 free and high quality without font serif to choose here. I'm sure you can find a desired.

  • According to error message: the file archive part of Adobe first 11 elements is missing, you need all the parts into the same folder in order to extract the Adobe Premiere elements 11.  You can download all the parts.

    Can someone help me please? When I try to download my software which is: adobe photoshop elements and adobe elements first I get this error message below.

    The file archive part of Adobe first 11 elements is missing, you have all the parts in the same folder in order to extract Adobe Premiere elements 11.  You can download all the parts.

    Kathryn

    Info: you are now discussing with Emmanuel.

    Emmanuel: Hello! Welcome to Adobe support.

    Emmanuel: I would like to please a moment so that I look into your account & check the details.

    Kathryn Saunders: sure

    Kathryn Saunders: Your file has been successfully downloaded: adobe. JPG.

    Emmanuel: You're tgrying to download the version of Photoshop elements 11.0?

    Emmanuel: tent *.

    Kathryn Saunders: YES this one both the primers we

    Info: your chat transcript will be sent to [email protected] at the end of your cat.

    Emmanuel: FYI, we do not have help and support elements 11.0 on the cat, we help you for version 14 on cat items

    Kathryn Saunders: wow so what do I do now?

    Emmanuel: you can visit our forums.adobe.com to display the send request and get the solution

    Emmanuel:

    Kathryn Saunders: OMG this is so not cool

    Emmanuel: I apologize for the inconvenience.

    Kathryn Saunders: I pay a lot of dollars for this software and can not download it even

    Kathryn Saunders: Not cool at all

    Kathryn Saunders: So it's a great way to make people continue to buy the product buy pass?

    Emmanuel: To get all help and support for the old version, you must visit our forums.adobe.com to display the send request and get the solution

    Kathryn Saunders: OK thanks anyway

    Emmanuel: Thank you for contacting Adobe. Good bye.

  • using rownum with order by

    Hi all

    I want to use rownum with order of clause-

    When I use an order clause in the select query, I get so many lines that I don't want.
    I have average-i want only two first rows according to the order of.

    EG. - Select employee_id, salary of the order of salary employees;
    EMPLOYEE_ID, FIRST_NAME SALARY
    ----------- -------------------- --------
    132 2100 TJ
    Steven 128 2200
    2200 hazelnut 136
    James 127 2400
    135 Ki 2400

    now, I just want to see the first two lines of the output above.
    any oneone please help does
    SQL> SELECT *
    FROM   (SELECT employee_id,
                   first_name,
                   salary
            FROM   employees
            ORDER  BY salary)
    WHERE  ROWNUM < 3;   2    3    4    5    6    7  
    
    EMPLOYEE_ID FIRST_NAME               SALARY
    ----------- -------------------- ----------
            132 TJ                         2100
            128 Steven                     2200
    
  • How to navigate using the TOC order Prev and next button

    Hello

    I am looking for a Previous Page / Next Page buttons who use rather the order of the table of contents to access the history list.

    Currently, the project shows previous Page / Next Page buttons. But these buttons will only work if the pages were visited.

    Do you think, it does not exist? If so, it would work for HTML HELP project, built with RH8. I think that javascript or HTML might work for these functions.

    Thank you for helping me.

    Christophe GONZALEZ

    Hello

    Your window has the sequences to browse?

    Take a bow

    Willam

  • Error that using TO_CHAR (TRUNC (SYSDATE), 'DAY') FROM DUAL

    Hello everyone.

    I have a pl/sql procedure that contains TO_CHAR (TRUNC (SYSDATE), 'DAY') FROM DUAL to capture the DAY in a variable. Now when I access this procedure of someother application (Workflow), I get the error ORA-01841: (full) year must be understood between-4713 and 9999 and not be 0.

    If I do not use TO_CHAR (TRUNC (SYSDATE), 'DAY') and hardcode the value, it throws no error.

    Any ideas on this error?

    Is this something to do with the NLS_DATE?

    Thank you

    Kind regards

    Pavan K

    >
    ...

    IF (TRIM (SAT_DAY) = 'SATURDAY')
    THEN
    L_DAYS: = L_DAYS + 2;
    ELSIF (TRIM (SAT_DAY) = "SUNDAY")
    THEN
    L_DAYS: = L_DAYS + 1;
    ON THE OTHER
    L_DAYS: = 1; - FND_PROFILE. VALUE ('DSD_PAF_TIMEOUT'); -Getting the value of timeouit in days
    END IF;
    L_DAYS: = L_DAYS * 24 * 60;

    First, you add two days if it's a Sunday.
    Then you multiply by 24 * 60.
    Are you sure that this logic is ok?

    I guess you just use bad values for the L_days parameter.

    The difference between last Friday and today, without doubt is:

    last Friday, the variable L_days has been VERY VERY VERY big, for example 20000000 = (x + 2) * 24 * 60)

    Today, it's only 1 * 24 * 60 = 1440.

    Published by: W. Sven on September 21, 2009 18:01

    Looking at the error message...

    ORA-01841: (full) year must be between-4713 and 9999

    My current guess is that you have created a date that goes beyond the year 9999.

    Published by: W. Sven on September 21, 2009 18:05

  • SQL (body of function from PL/SQL returning the SQL) query when you use to_char

    We are trying to build a page of Type SQL Query report (body of function from PL/SQL returning SQL query).
    our request is simple, to extract the month of the column recording_date.

    declare
    l_query varchar2 (1000);
    Start
    l_query: = 'select to_char (recording_date, 'MM') of re_productive;
    Return l_query;
    end;

    but we would like the following for this query problem

    Function returning SQL query: query cannot be parsed in the generator. If you believe that your query is syntactically correct, check the box of generic columns below the source of the region without analysis.
    (ORA-06550: line 4, column 42: PLS-00103: encountered the symbol "MY" what awaits one of the following values:.) (* @ % & = - +; <>/ at is mod remains not rem <>or! = or ~ = > = < = <>and or as between | multiset Member SUBMULTISET_ the symbol ".") was inserted before 'MY' to continue.)

    Notes:
    1 - the request is correct and it has been tested under sqlplus and toad.
    2. we tried option use generic name (analysis of query runtime only) column, but we get the same problem.


    any quick help please.

    Hello

    You have not escaped your quote in the string. Try this...

    DECLARE
    l_query VARCHAR2(32767);
    
    BEGIN
    
    l_query:= 'select to_char(recording_date,''MM'') from re_productive';
    
    RETURN l_query;
    
    END;
    

    See you soon

    Ben

  • P780 SP Flash Tool does not, received a used phone, but ordered a new.

    I ordered myself a P780 on Amazon a month ago, apparently the seller has shipped me a second hand so phone I ordered a new one. The P780 I received was rooted. Now, I try to get the stock ROM using the tool of Flash SP.

    But there always seems to be stuck on the research.

    I have an itch that tells me I have to install the driver MTK65xx Preloader.

    I haven't tried Windows 7 no luck, Windows 8 does not work either.

    Someone at - it an idea how to get MS Flash tool works correctly? Or the measures they have taken on a new installation of Windows?

    Resolved, started Windows 8.1 with driver signature enforcement disabled. Then everything went well. And the unsigned drivers installed successfully.

  • Can't unzip the files using the Windows Vista option extract all

    I tried to unzip the files, I have downloaded from the Web site by using the context menu "extract all... "on the file.  I have a Board error saying that the compressed (zipped) folder is empty.  If I try a double click on the file, I get the message that the zip file is not valid.  This has happened to every zip file I tried to unpack so far.  The only files I can unpack so far are those I zipped myself using the context menu "send to folder of Compssed of-->" of Windows Vista.  Any suggestions?

    Hi Eddie Hersh,.

    Thanks for choosing the Windows Vista Forum.

    1 how long have you had this problem?

    2. If it works well before?

    Make sure that the download of the file is not corrupted.

    You can perform the steps in the link below and check if it works.

    Restore and return the file Association in Windows Vista if Original

    1. click on start, and then type regedit in start search and press ENTER.

    2. navigate to the following registry branch:

    NtVersion ntVersion\Explorer\FileExts\ [ext]

    Replace the [exe] with the real extension of the file you want to restore the file type association to return to the default Windows Vista original. If you unsure, simply browse through all the Sub-touche under FileExts.

    3. delete the subkey named UserChoice.

    4. exit the registry editor.

    WARNING:

    Change the settings of the REGISTRY can cause serious problems that may prevent your computer from starting properly. Microsoft cannot guarantee that problems resulting from the REGISTRY settings configuration can be solved. Changes to these settings are at your own risk...

    Compress and uncompress files (zip files) - http://windowshelp.microsoft.com/Windows/en-US/Help/7050d809-c761-43d4-aae7-587550cd341a1033.mspx

    Kind regards

    Marnie.

  • How can I reset the compressed files (zipped) for normal zipped folders of other programs that i'ved open with in order to extract the zipped files and download the zipped files? __

    I changed somhow setting folder zipped removable zipped files to adobe reader and internet explore and I think it's by using the open with option and I need to reset the zipped folder that looks like a folder with a zipper that can be extracted, so I can download and extract zipped files! But how?

    Hello

    1st 3 here should fix you up

    How to restore Vista built-in ZIP files Support
    http://www.Vistax64.com/tutorials/65254-zip-file-support-restore.html
    How to enable or disable the files compressed in Vista
    http://www.Vistax64.com/tutorials/93827-zip-file-compressed-folders.html
    Restore the Type Associations by default Vista file extensions
    http://www.Vistax64.com/tutorials/233243-default-file-type-associations-restore.html

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

    How Unassociate a Type of Extension file in Vista - and a utility to help
    http://www.Vistax64.com/tutorials/91920-unassociate-file-extention-type.html
    Restore and return the file Association in Windows Vista if Original
    http://www.mydigitallife.info/2008/06/22/restore-and-reset-file-association-in-Windows-Vista-back-to-original-default/

    Reset and Fix Broken Windows Vista file Ext and Type Associations (include EXE, COM, SYS, ZIP, LNK,
    Folder, drive)
    http://www.mydigitallife.info/2008/06/22/reset-and-fix-broken-Windows-Vista-file-ext-and-type-associations-include-exe-com-sys-zip-lnk-folder-drive/

    For Windows Vista file association problems
    http://www.Winhelponline.com/articles/105/1/file-association-fixes-for-Windows-Vista.html

    I hope this helps.
    Rob - bicycle - Mark Twain said it is good.

  • generation of sequence using rownum and order of

    Hi all

    Need to generate a sequence number based on a column value in a table.

    When you try to insert into a table by using the order by and rownum, I am not able to do the same thing.

    Here is a simple example to show this... need help how to insert a sequence field in the base table a column value...

    create table test1(col1 number);
    
    
    insert into test1 values(1);
    insert into test1 values(2);
    
    
    
    
    insert into test1 values(4);
    insert into test1 values(3);
    

    select * from test1;
    

    1

    2

    4

    3

    Now, I'm trying to insert into test1 values-based test2:

    create table test2(col1 number,seq number);
    
    
    insert into test2 (select col1,rownum from test1  order by col1 asc);
    

    ORA-00907: lack of right parenthesis

    So I tried with:

    insert into test2 select col1,rownum from test1  order by col1 asc;
    

    It worked, but the sequence is not generated according to the ranking...

    COL1SEQ

    11
    22
    34
    43

    can someone please help...

    Thanks in advance...

    MRK...

    Another way would be to use analytical functions. These have the advantange of being independent of the order of... in fact, you could use serveral where everyone has his own sort.

    Select col1

    row_number() over (order by col1 CSA) seq_asc

    row_number() over (order by col1 desc) seq_desc

    of test1

  • Hi, I recently bought single-app creative cloud for Acrobat Pro DC membership in a one-year contract, but now realize that my computor software is too old for me to even use it. Order is not yet passed through yet since I just bought it t

    Hi, I recently bought single-app creative cloud for Acrobat Pro DC membership in a one-year contract, but now realize that my software is too old for me to even use it. The order has not yet crossed yet since I just bought it today, is it possible that I can cancel?

    Hey katherineh32317543,

    You might need navigate to the link for the same mentioned below:

    Cancel your membership creative cloud

    Let me know if you need more assistance.

    Kind regards

    Ana Maria

  • ROWNUM returns which you would naturally expect when it is used with an ORDER BY on a very large result set?

    For security reasons, I removed the column names and the name of the table to this request, but there is no WHERE clause, and this includes the ORDER byclause complete.

    Select p.cc,

    p.yy,

    p.mm,

    p.DD,

    p.ref_no,

    p.seconds,

    p.deci_mal,

    Cast (rownum as number (14)) as arpds_id

    p

    order of p.cc,

    p.yy,

    p.mm,

    p.DD,

    p.ref_no,

    p.seconds,

    p.deci_mal

    ;

    The table containing the former payments, which took thousands of lines, where each column is the same and had over 15 million total lines, we have add a primary key (ARPDS_ID).

    I expected the ROWNUM to represent the line number * after * the lines are sorted by the ORDER BY clause.  However, we have identified at least one account if it wasn't the case.

    Here's the relevant fields for this account, sort by my ARPDS_ID.  As you can see, the second row has clearly a REF_NO higher, but an ARPDS_ID lower than the third row.

    CC AA MM JJ REF_NO SECONDS DECI_MAL ARPDS_ID

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

    20 13 05 25 1258 57 00 15584205

    20 13 06 04 1718 56 00 15669414

    20 13 06 04 1711 48 00 15682078

    Can someone help me understand why this has happened?  I didn't when it was first brought to my attention, and the database restored which contained the tmp table real (global temporary not) we have created with the query above, so I can prove me as the above query * actually * created these results.  Is that I saw it with my own eyes I thought this happened.

    Thank you

    Post edited by: mattknowles PS - What happened to the Post Preview feature?  Am I just not see it?

    Hello

    Everything you would expect of course, ROWNUM is probably not do.

    ROWNUM is assigned as lines are taken from the table (or subquery), before the ORDER BY clause.

    If you want to ROWNUM to reflect a particular order, then an ORDER BY in a subquery and use ROWNUM in the Super request,

    WITH ordered_data AS

    (

    SELECT cc yy, mm, DD, ref_no, seconds, deci_mal

    P

    ORDER BY cc, yy, mm, DD, ref_no, seconds, deci_mal

    )

    SELECT o.*

    CAST (ROWNUM AS NUMBER (14)) AS arpds_id

    Of ordered_data o

    ;

    If the problem is more complicated than what you have posted, you can use the analytic ROW_NUMBER function instead of ROWNUM.

  • using XPath with SQL to extract XML data

    Given the data like this:
    <?xml version="1.0"?>
    <ExtendedData>
       <Parameter name="CALLHOLD"><BooleanValue>true</BooleanValue></Parameter>
    
      <Parameter xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="BARRING_PASSWORD" xsi:nil="true"/>
    
      <Parameter name="ALLCF"><BooleanValue>true</BooleanValue></Parameter>
    
      <Parameter name="RealProv"><BooleanValue>false</BooleanValue></Parameter>
    
    </ExtendedData>
    I usually use extractValue as shown below, for example function to extract the value for the last parameter in the above data, for example:
    select extractValue(extended_data,'/ExtendedData/Parameter[@name="RealProv"]/BooleanValue') "my_column_alias" from table
    Any ideas on how can I return the value of the parameter xsi: Nil for that node:
    <Parameter xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="BARRING_PASSWORD" xsi:nil="true"/>
    I would like to extract the
    true
    in
    xsi:nil="true"
    ...

    Thank you

    Published by: HouseofHunger on May 15, 2012 14:13

    Published by: HouseofHunger on May 15, 2012 14:13

    ExtractValue() has a third parameter, that we can use to declare the namespace mappings:

    SQL> with sample_data as (
      2    select xmltype('
      3  
      4    true
      5    
      6    true
      7    false
      8  ') doc
      9    from dual
     10  )
     11  select extractvalue(
     12           doc
     13         , '/ExtendedData/Parameter[@name="BARRING_PASSWORD"]/@xsi:nil'
     14         , 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"'
     15         )
     16  from sample_data
     17  ;
    
    EXTRACTVALUE(DOC,'/EXTENDEDDAT
    --------------------------------------------------------------------------------
    true
     
    

    If you are on 11.2.0.2 and upward, extractvalue() is obsolete.
    Must use XMLCast/XMLQuery instead:

    SQL> with sample_data as (
      2    select xmltype('
      3  
      4    true
      5    
      6    true
      7    false
      8  ') doc
      9    from dual
     10  )
     11  select xmlcast(
     12           xmlquery('/ExtendedData/Parameter[@name="BARRING_PASSWORD"]/@xsi:nil'
     13            passing doc
     14            returning content
     15           ) as varchar2(5)
     16         )
     17  from sample_data
     18  ;
    
    XMLCAST(XMLQUERY('/EXTENDEDDAT
    ------------------------------
    true
     
    

    Note: the prefix xsi is predefined when using Oracle's XQuery, so in this case we must explicitly declare.

    Published by: odie_63 on May 15, 2012 15:23

  • using to_char ('date', IW) in a different way

    Hello all;

    I have the sample data below
    create table table_one
    (
     v_id varchar2(60),
     close_date date
    );
    
    insert into table_one
      (v_id, close_date)
    values
      ('A', to_date('1/1/2010 4:47:09 PM', 'MM/DD/YYYY HH:MI:SS:AM'));  
    insert into table_one
      (v_id, close_date)
    values
      ('A', to_date('1/2/2010 2:47:09 PM', 'MM/DD/YYYY HH:MI:SS:AM'));  
    insert into table_one
      (v_id, close_date)
    values
      ('A', to_date('1/3/2010 1:47:19 PM', 'MM/DD/YYYY HH:MI:SS:AM'));   
    insert into table_one
      (v_id, close_date)
    values
      ('D', to_date('1/4/2010 5:47:09 PM', 'MM/DD/YYYY HH:MI:SS:AM'));  
    insert into table_one
      (v_id, close_date)
    values
      ('D', to_date('1/5/2010 4:47:09 PM', 'MM/DD/YYYY HH:MI:SS:AM'));  
    insert into table_one
      (v_id, close_date)
    values
      ('D', to_date('1/6/2010 5:17:09 PM', 'MM/DD/YYYY HH:MI:SS:AM'));  
    
    
    insert into table_one
      (v_id, close_date)
    values
      ('D', to_date('1/7/2010 5:17:09 PM', 'MM/DD/YYYY HH:MI:SS:AM'));  
      insert into table_one
      (v_id, close_date)
    values
      ('D', to_date('1/8/2010 5:17:09 PM', 'MM/DD/YYYY HH:MI:SS:AM'));  
      insert into table_one
      (v_id, close_date)
    values
      ('D', to_date('1/9/2010 5:17:09 PM', 'MM/DD/YYYY HH:MI:SS:AM'));  
      insert into table_one
      (v_id, close_date)
    values
      ('D', to_date('1/10/2010 5:17:09 PM', 'MM/DD/YYYY HH:MI:SS:AM'));  
      insert into table_one
      (v_id, close_date)
    values
      ('L', to_date('1/11/2010 5:17:09 PM', 'MM/DD/YYYY HH:MI:SS:AM'));  
      insert into table_one
      (v_id, close_date)
    values
      ('L', to_date('1/12/2010 5:17:09 PM', 'MM/DD/YYYY HH:MI:SS:AM'));  
      insert into table_one
      (v_id, close_date)
    values
      ('L', to_date('1/13/2010 5:17:09 PM', 'MM/DD/YYYY HH:MI:SS:AM'));  
        insert into table_one
      (v_id, close_date)
    values
      ('L', to_date('1/14/2010 5:17:09 PM', 'MM/DD/YYYY HH:MI:SS:AM'));  
    and basically, I have the following sql to be changed
      select y.v_id, to_char(y.close_date, 'IW') as d_date   from table_one y
      group by to_char(y.close_date, 'IW'), y.v_id;
    this query gives me this output below
    
    V_ID     D_DATE
    D              01
    L               02
    A               53
    However, although that's what I want instead
    V_ID             D_DATE
    D                 1/4/2010  - 1/10/2010
    L                  1/11/2010 - 1/17/2010
    A                 1/1/2010 - 1/3/2010
    This is based on the ISO week. Thank you.
    Any help is appreciated

    Hello

    Thanks for posting the CREATE TABLE and INSERT statements; It is very useful.
    It would be even more useful if you explain how you get the results you want from this sample data.
    Rather than display the week number of the group, it seems that you want to display the first and last date of the group. Is this fair?

    If so:

    SELECT    y.v_id
    ,       TO_CHAR ( MIN (y.close_date)
                  , 'fmMM/DD/YYYY'
                )
          ||  ' - '
          ||  TO_CHAR ( MAX (y.close_date)
                  , 'fmMM/DD/YYYY'
                )     AS d_date
    FROM       table_one     y
    GROUP BY  TO_CHAR (y.close_date, 'IW')
    ,            y.v_id;
    

Maybe you are looking for

  • Other people sees the start of the Transflective TFT on Qosmio X 300

    Hello I would like to know if other people are able to see the start of the Transflective TFT on the Toshiba Qosmio X 300.A in addition explained; When I press the power button the Transflective TFT is on a few seconds after that. I see the TFT creat

  • Satellite A100 Wireles not found/lost?

    I installed/used the wireless for half a year. now it doesn't! ' t work and it still says 'kein drahtlosnetzwerk found' / and seeks with the Launcher configfree saw that there is no shown 'gerät' / it does not have the toshiba Wireless LAN Mini PC Ca

  • detection of cells limited

    For many years around 2002, I downloaded a sample file called "culture.zip", which contained some culture.vi. Culture.VI helped the limit of a cell to be acquired from a still image. I still of the Moose culture zip coming of NOR, but it dosent seem

  • ATC-705 query re a Revo

    When I start my office in the morning I get a popup saying a Revo is not connected, and I should connect and sign in.  Is there a way to stop this?  (I don't know really what is a Revo.) Thank you Tom

  • Recycle Bin in Windows Vista is empty but still shows the icon there files it contains?

    Recently, I noticed that my trash wasn't showing it was empty, although there is nothing in the tray. This is also true when there is something in the tray, it will show as empty when I know that there is a file in there. I have run norton security,