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;

Tags: Database

Similar Questions

  • I am creating a stamp of Certification of drawing dynamic shop with fields of text 'Name' and 'Date '. I tried different ways within Javascript, but I can't seem to make it work. The Date and time remains static on the stamp when it is inserted and

    I am creating a stamp of Certification of drawing dynamic shop with fields of text 'Name' and 'Date '. I tried different ways within Javascript, but I can't seem to make it work. The Date and time remains static on the stamp when inserted and always reflect when the stamp was created and the name is always my name. I try to have the user name or the username inserted so that he who is the insertion of the postmark of the stamp automatically inserts their name and what day and time the stap is inserted. I can't get this dynamic stamp works like the default Adobe Acrobat Dynamic stamps. Can anyone help with this one. Thank you

    Have you created a page template for your stamp? Did name the template of the page correctly? It's the right format:

    #InternalStampName = display name of stamp

  • What are the different way of seeing the visitor record or profile captures information using eloqua?

    What are the different way of seeing the visitor record or profile captures information using eloqua?

    Hey Sanny,.

    There are three ways to view the visitor record or profile captures information using eloqua:

    • Contact & prospect downloads
    • submission of form data
    • cookie script & follow-up

    Thank you

  • Hello, my phone pulled from my class at school and it has no data on it, so I did not no how to locate without using find my iphone is there another way I could find as soon as possible

    Hello, my phone pulled from my class at school and it has no data on it, so I did not no how to locate without using find my iphone is there another way I could find as soon as possible

    Go to iCloud.com

    Then sign in with your Apple ID and password, then click the Find iPhone.

    If this does not help, see: If find my iPhone is not activated on your missing device > what to do if your iOS device is lost or stolen

  • update a table using a date to_char

    Hello all;

    I have the following query and the table below
    create table t1
    ( 
           cid varchar2(200),
           yearid varchar2(200),
           begin_date date
           );
    
     insert into t1
               (cid, yearid, begin_date)
             values
               ('A', '2010_1', sysdate);
      insert into t1
               (cid, yearid, begin_date)
             values
               ('B', '2010_1', to_date('03/04/2011', 'MM/DD/YYYY'));
    insert into t1
               (cid, yearid, begin_date)
             values
               ('C', '2010_1', to_date('01/02/2011', 'MM/DD/YYYY'));
    and I have the following update statement
       update t1 t
           set t.yearid = '2011_1'
           where to_char(t.begin_date, 'YYYY') = substr(t.yearid, 1, 4);
    what I'm trying is basically update table t1 yearid which is a varchar2 in to_char start the date are irregular... so in my case of the sample,

    TO_CHAR date start back a 2011
    Therefore, the yearid must be 2011_1 instead.

    However, my udate statement does not work well

    Don't know what exactly you want, but it looks like everything that you need is to change = to! = where year clause and using begin_date in update the value:

    SQL> select * from t1;
    
    CID YEARID     BEGIN_DAT
    --- ---------- ---------
    A   2010_1     26-JAN-11
    B   2010_1     04-MAR-11
    C   2010_1     02-JAN-11
    
    SQL> update t1 t
      2         set t.yearid = to_char(t.begin_date, 'YYYY') || '_1'
      3         where to_char(t.begin_date, 'YYYY') != substr(t.yearid, 1, 4);
    
    3 rows updated.
    
    SQL> select * from t1
      2  /
    
    CID YEARID     BEGIN_DAT
    --- ---------- ---------
    A   2011_1     26-JAN-11
    B   2011_1     04-MAR-11
    C   2011_1     02-JAN-11
    
    SQL> 
    

    SY.

  • How can you use a single image and change it in three different ways to export later?

    I am a new user of Lightroom 3.  How to use the same image and change several ways to produce multiple images of later export?  For example, I have a photo of a bride and groom.  I want to use this image and create a color image, a black and white image and end up with their hands.

    No, you can add them at any time.

  • IPhone-to-iPad call phone cellular continuity uses the data

    Many times I drive to work using my iPad Mini 4 WiFi + cell phones driving to work to play music of different applications via bluetooth to my car audio system.

    Whenever my phone rings, my iPad has the T-Mobile (my support for iPhone & iPad) also allows cellular continuity. My question is, if I were to answer the call on my iPad I will be charged data or the call still counts against cellular minutes? So, basically the iPad use VoIP (data) or VoLTE (phone calls / minutes) to manage the call? Thanks for any help!

    Updated - talked with my contact at T-Mobile, who is Advisor senior technical/engineering. He said phone calls on iPad via transfer cell/continuity is currently working on Facetime Audio that is essentially a VoIP service and use the cell data.

    However, T-Mobile is looking for ways to eliminate the use of data for its customers on Facetime Audio (and perhaps even Facetime video as well) through their programs free music and frenzy on. If that happens, it would be incredible!

  • Different ways to run?

    We have written a c sharp application which is a wrapper of GUI TestStand to hand - hold the operator thanks to the installation and execution of a test. I noticed the following behavior differences with each of the different ways to start a file of sequence running:

    (a) when we useSequenceFileViewMgr.Run () to start execution, TestStand prompt is not a serial number of UUT and it didn't generate a DisplayReport event.

    (b) when we use SequenceFileViewMgr.GetCommand (CommandKinds.CommandKind_ExecutionEntryPoints_Set). Execute (true) to start execution, TestStand is fast for a serial number of UUT and he generates an DisplayReport event.

    (c) when we useSequenceFileViewMgr.GetCommand (CommandKinds.CommandKind_ExecutionEntryPoints_Set, 1). Execute (true) to start execution, TestStand didn't request a serial number details of UUT and he generates an DisplayReport event.

    Are there other ways (best ways) to start execution of a c sharp application?

    'C' behavior is the behavior I'm looking for, but I understand why the calls have different results?

    Can someone enlighten me?

    tlaford,

    What you're essentially doing is running execution of different entry points.  If you look at the menu run in the sequence editor, you will see three options (with the default process model, if you have a custom process template, you will have a different number).

    1. Test DUT

    2. Simple pass

    3. Run

    When you call. Run() you do the same operation as Run in the menu.  This is just the selected sequence and nothing else.  Great for debugging, but uses not the framework process model.

    When you use one of the ExecutionEntryPoints, you perform a execution of the entry points of the process template.  Those who usually call in the sequence MainSequence your file of the client's sequence.  And they perform other operations (such as the data collection of the object to measure and reports) around the execution of your customer file.  Default process templates are TestUUTs as index 0 and SinglePass as index 1.

    With the help of the SequenceFileViewMgr is the best way to start a new run since a UI programmatically.

    I hope this helps.

  • Date/time format and different regions

    I'm developing an application in this case to the United States on the English LV2009 software.  This application will be installed in many parts of the world, and I just discovered a problem with the date and time that I try to understand.  A screenshot of the application running on a Chinese computer is attached.  At the top right there is a 'results save location' which has a month and year added file name.  I use the date/time format with modifiers for the name of the month and the year in 4 digits (%B %Y).  On my PC, it displays in July 2010, but on Chinese computer it 7 01.  In addition, the reason that it says wrong serial number is that I compare the SN 2-digit year, and it seems to enter it correctly.

    On my PC, I tried to change my date settings in Windows and it doesn't seem to affect the production, as it does on Chinese computer.  I know there is a UTC Boolean selector which can be activated.  That will make a difference in the way that the date is displayed by this function?

    This is one of the few issues I encountered when developing a program for several regions, but it is currently the only one, I have not yet solved.

    I would expect month name to be specific langauge.

    For example, the word April in French is April and is abbreviated Apr. I would use a number instead of the name.

    The thai calendar + 543 years compared to the Western calendar, so a PC Thai could show a specific locale of 2553-07-13 date. Your computer may display 13/07/2010. I'm sure that the year of the Chinese calendar is different from that of the Western calendar.

    Using UTC should force LabVIEW to use the Gregorian calendar, based on the ISO-8601standard.

    Because your users work with technology and would probably recognize a Gregorian day/month/year combo I would stick with % Y_ m_ % d. % and UTC = TRUE.

    I contributed a VI to the community OR that you could use if you wish. It has many options and is based on ISO-8601

    .

    http://decibel.NI.com/content/docs/doc-7199

  • the advantage of using the date dimension.

    Hi gurus,
    I have a table of facts with 5 different dates as the shipping date, the order date.
    My question is
    Case 1. in fact, table I store date_keys (substitution integers) and create several date dimensions (alas) for each type of date as a date_dimension alias for the shipping date, an alias for the date of the order etc (in the model of declaration).

    Case 2: I just avoid using the date and just store date dimension (no integers) in fact table.
    In this way I will save 5 joints in 5 dimensions of different date.
    Note: I have need of these 5 participates in the declaration of model that will be used to create reports, not in the model ETL in dimension model ETL that one date will be there, but we must create on alias the dimension date for each type of report date.

    So, I was wondering what is the advantage of using the date dimension?

    It is more a question of design/statement of a question of ETL/ODI;).

    The advantage of the dimension is that you can select or aggregate data by year, weekends, quarter, month, day of the week...
    If you only keep the date, you had all these complexes of the formula in logic or calculated items columns (assuming you are using OBIEE). Performances will be affected and the code will be duplicated in many places.

    Hope that it answers the question.

    Jerome

  • Use the data from a DataSet as a source for another (the join between the sets of data)

    Hello. I come with a problem, very simple, but which I think is not implemented in the beer Pub.

    In the DataModel, I create a DataSet, providing some data (for example, a string from a web service), and after this, I create another set of data that uses this string as a parameter for a database query. Is this possible? The only link I found between the sets of data is only this concatenation of the main data set.

    Is there a way that I can do? Thank you!

    * [url http://www.java-forums.org/blogs/advanced-java/collection/] Java collection *.

    In Publisher 10 g and sooner you can use a data model to the join and the structure of data from different sources SQL.

    In Publisher, 11g, you can join data sets for which Publisher can 'know' on the data fields. For example. In addition to SQL data sets, you can reach Excel, LDAP, MDX and answers. Web Services, like XML file are data sets that editor does not know the data fields, so unfortunately, no way to join them... I know.

    Also, true that LOVs can either be SQL or data fixed (i.e. the entered values).

    Allowing the Web Service as a source of LOV or a way to define data fields, it's something for us to consider for a future version.

    Mike

  • I have 2 phones on my plan. If someone uses the Apple ID to any other phone/account to use my data or theirs?

    I have 2 phones on my plan. Me and my son, I noticed that his use of data was riding way, actually on the 10 GB.  I finally find out of his girlfriend has his Apple ID and password and remains connected to his account.  Not happy to know that none of my text conversations are private, she received all her messages too!  She has somehow their Apple ID interconnected.  Is this using our data? She uses my data on my plan when it is connected on his Apple ID from his phone?

    If it uses the same account as yours while it uses your data. But if it is recorded in account of another person who does not use your data.

  • When I change the Option for the Applications of Document Adobe, Firefox always manages documents in a different way.

    I changed my Options ask me each time I want to do with a pdf document. It does not work. What happens each time I click on a PDF as an attachment in e-mail or on a Web site, is that a Windows Explorer window asks me where I want to save the file. I don't want to save it, just open. I had always presented a selection of Firefox in the past, but the box Firefox offering options for me is no longer appears. I tried to change my Options/Applications in different ways, but the practice seems so have no effect at all. I'm using Firefox 27.0.1 on a Windows 7 operating system.

    Hello, to change the options for a PDF file, go to firefox > options > applications and scroll down and set the default action for the portable document (pdf) format.

    How to disable the built-in PDF Viewer and use another Viewer

  • Hide using the date of beginning and end of line

    Is there a way to hide using the start date and end date of line

    One way to do is to add a filter column (which may hide once it is configured) like this:

    The formula in D2, filled to the bottom, is:

    = AND(A2≥$B$8,A2≤$B$9)

    The filter (on column D) looks like this in the right panel:

    C9 formula is:

    = SUMIFS(C,A,">="&B8,A,"<="&B9)

    After changing the end date of 2014-12-31, you get this:

    I left column displayed D just for illustration.

    SG

  • Use of data excessive mobile (cellular data) of Documents &amp; Sync

    I had a problem during the last 3 or 4 days of my iPhone using excessive amounts of mobile data.

    Typically, in a month, I use about 3 GB of data. In the last 4 days I used more 2 GB despite spending most of the time in places with WiFi.

    Once I realized that something was up (when I had to buy updates data in 72hrs 2 x 1 GB). I started to look for a cause by using the data provided under settings > Mobile Data (cellular data).

    Tried a couple of things:

    (1) under settings > iTunes & App Stores "use mobile data" has been attributed to.

    It was weird, I'm pretty sure the last time I checked it was off. In any case, I changed it to off.

    Under data Mobile > System Services, I could see the data used by iTunes had fallen back. This has helped reduce the use of data, but has not solved the problem.

    (2) under settings > iCloud > iCloud Drive 'use mobile data' has been assigned to.

    Didn't know it, but he found Googling for a solution. I changed it to off. Makes very little difference.

    After making these changes I switched back on Mobile Data. I always saw use of massive data, about 50 MB in 30 minutes.

    When I checked in Mobile Data > Services system by far the largest user of data is listed as 'Documents & Sync '. I don't know what it does.

    I signed up for my iCloud on the phone. This sewing to help, but I couldn't leave it that way for a long time, because missed me my calendar and contacts so I signed in and turn all my iCloud (except mail) services.

    So, as soon as now I have dial-up mobile data wide completely. I'm only able to use my phone on WiFi, so it is essentially a super expensive iPod Touch.

    I really need help with this, I hope someone can tell me please a solution or at least explain what might use data labeled as «Documents & Sync»

    If I can't get to the bottom of it I'll have to switch to another phone, my career here in New Zealand do not offer unlimited plans :-(

    Some details on my phone and the settings:

    • iPhone running iOS 9.2.1 6 (13D 20)
    • Phone has 128 GB of storage with about 10 GB of free space
    • iCloud, I use it for everything except the storage of email and document
    • I have iTunes game, Apple Music/subscriptions
    • iCloud library is running
    • All I can find with a setting for her except for Apple's music is set to use only data on WiFi

    An update.

    It has been suggested that I have disable Wi - Fi pass to see if that would help.

    I ran several tests. This apparently made no difference.

    Tests in 15 minutes will help the periods that I sometimes see very low use with WiFi help on & I see still on a very high, sometimes use 4G data and WiFi turned off.

    Worst when I was walking with WiFi and 4G data but WiFi help out I've seen data use of 39.5 MB in 15 minutes, this 35.1 MB was allocated the mysterious return «data & Sync»

    Test details:

    Test 1.

    local time 10:00-10:15.

    • WiFi off
    • 4 G Mobile Data on and connected with good signal
    • Assist off WiFi
    • Changing the mode of the aircraft at the beginning of the test
    • Stationary situation during the test

    Total mobile data use 1.4 MB

    (Documents & Sync 3.2 KB)

    Test 2.

    local time 10:30-10:45.

    • WiFi on and connected with good signal
    • 4 G Mobile Data on and connected with good signal
    • Assist of WiFi on
    • Changing the mode of the aircraft at the beginning of the test
    • Stationary situation during the test

    Use of mobile data total 57.8 KB

    (Documents & Sync 2.1 KB)

    Test 3.

    local time 13:00-13:15.

    • WiFi off
    • 4 G Mobile Data on and connected with good signal
    • Assist off WiFi
    • Changing the mode of the aircraft at the beginning of the test
    • Stationary situation during the test

    Total mobile data use 9.0 MB

    (Documents & Sync 28.6 KB)

    Test 4.

    local time 13:20-13:35.

    • WiFi on but not connected to a constant signal
    • 4 G Mobile Data on and connected with good signal
    • Assist off WiFi
    • Changing the mode of the aircraft at the beginning of the test
    • Mobile location (market) during the test

    Total mobile data use 39.5 MB

    (Documents & Sync 35.1 MB!)

Maybe you are looking for