How to duplicate the data in a column?

I have

< code >

SELECT '1' DFILE
'aaa' ANAME
'no' poles
OF THE DOUBLE
UNION
SELECT '1' DFILE
'bbb' ANAME
'no' POLES
OF THE DOUBLE
UNION
SELECT '0' DFILE
'ccc' ANAME
'yes' IMPERIOUS
OF THE DOUBLE
< code >

I want the output to be

DFILE imperious aname
1 Yes aaa
1 Yes bbb
0 Yes ccc

I'll be pulling data from 3 files and do a union. I just give a simple example
where I want the value of "ccc" in the column of the other 2 queries.
CCC will have always a '0' for form preprinted.

Suggestions?

TIA
Steve42

Hello

If you want that each row of the result set to contain something that reflects the overall result (in this case, the value of the poles of the 1 row of the result set that's aname = "ccc"). This looks like a job for an analytic function.
Here's one way:

WITH     sample_data     AS
(
     SELECT '1' DFILE
     ,'aaa' ANAME
     ,'no' ahelp
     FROM DUAL
     UNION
     SELECT '1' DFILE
     ,'bbb' ANAME
     ,'no' AHELP
     FROM DUAL
     UNION
     SELECT '0' DFILE
     ,'ccc' ANAME
     ,'yes' AHELP
     FROM DUAL
)
SELECT     dfile
,     aname
,     MIN (CASE WHEN aname = 'ccc' THEN ahelp END)
             OVER ()                      AS ccc_ahelp
FROM     sample_data
;

What results would you if the result set does not contain a line with aname = "ccc"? The query above would have NULL in the last column.
What if there were 2 (or more) lines with aname = "ccc"? The query above takes the first value (in the normal sort order) of the lines with aname = "ccc". If they are all lucky to have the same value of poles, then, of course, this will be the first.

You may have noticed that this site deosn treat as anything special
Whenever you post formatted text on this site, type these 6 characters:

\


tag is exactly the same as the opening tag; don't use a '/'.

(small letters only, inside curly brackets) before and after each section of formatted text, to preserve spacing.  Note that the closing \

Tags: Database

Similar Questions

  • How to examine the date as 1 column value if the value of the column date is same?

    Hi all

    With trunc

    SELECT pointed_date,

    Qty.

    OF () SELECT Trunc (pointed_date) pointed_date,.

    SUM (Nvl (quantity, 0)) Qty.

    FROM table_1

    WHERE pointed_date > = Add_months (trunc (sysdate),-4)

    GROUP BY pointed_date( )

    ORDER BY pointed_date DESC

    output

    28/01/2015-30

    28/01/2015-30

    Without trunk


    SELECT pointed_date,

    Qty.

    FROM (SELECT pointed_date , pointed_date,)

    SUM (Nvl (quantity, 0)) Qty.

    FROM table_1

    WHERE pointed_date > = Add_months (trunc (sysdate),-12)

    GROUP BY pointed_date)

    ORDER BY pointed_date DESC

    output

    28/01/2015 01:01:56 - 30

    28/01/2015-30

    Suppose if I get two dates with less time diff then do as a Date like

    28/01/2015-30

    28/01/2015-30

    EXPECTED

    28/01/2015-60

    Thank you

    run something like below (you might indeed not have more than 9 months of data in the range you are looking at)

    Select months_between (sysdate, min (pointed_date)) months_of_data

    FROM table1

    where pointed_date > = add_months (sysdate,-12)

    Concerning

    Etbin

  • Multiple column trees: how to access the data in columns? There is a bug?

    Hello

    I have a strange problem. I use tree column multi like this:

    In this case, I have the tree column and two other custom columns.

    Now, how to access the data in the SECOND column?

    We can write all the data in a row thanks the EditElementTree:AddElement:ChildText, because it is an array of strings.

    However, when I want to read the data, I use ActiveCelltring, meaning that a SINGLE string and not a string table oO (so I only have the value of the first column and never others.

    So, I can do what I want? Is this a bug?

    Thank you very much

    R0b1n

    OK, I have the solution.

    We play with the ActiveColumnNumber attribute, to read the values of different...

    I left the message, it may be useful for later someboby

    R0b1n

  • Can someone show me how to get the data of this vi in four columns in a spreadsheet file.

    I'm trying to get the data into four columns on a worksheet. The data consists of two channels and two measures, a maximum voltage and a voltage after x seconds. I enclose the code. Any help would be great. Thank you.


  • How to find the date item was my favorites on Mozilla Firefox

    on system moot bookmark how to find the date of the bookmark?

    In bookmarks menu select organize bookmarks to open the bookmarks library. In the bookmarks library, click views, and then display the columns and then added. This will display a column showing when a bookmark has been added.

  • How to access the data of all users of a page?

    Hi all, I'm new to APEX and have a query.

    I have installed APEX on my local machine, create a workspace and added a few users to roles.

    I'm creating an application, similar to a library application, where I have a table that stores information of books (BOOK_ID, BOOK_NAME, etc.). I would like to create another BOOK_USER table with two columns BOOK_ID and USER_ID. BOOK_ID refers to the BOOKS table and I want to USER_ID to refer to the table that stores the information of the users of the workspace I use. Data entry would be a page that has two LOVs, one for the name of book (using BOOK_ID as value) and another for the user name (USER_ID, or another field APEX uses to store the ID of the user). I can do in APEX? I found ways to access and authenticate a user to a page, but how to get the data of all users in the workspace? In other words, how to get all the usernames in a LOV?

    As I am new to APEX, I would appreciate if anyone can guide me through the steps, or posting links to the tutorial, etc.

    I think you can do this by querying APEX_WORKSPACE_GROUP_USERS.

  • How to insert the data from the table file?

    I need to know that how can I insert data into multiple columns by file. I can simply insert data into a table of columns, but could not find a way to put the data in the column all.

    My data in a file store
    ************************************************text.txt***************
    133, nanny, nagina, 14 mph, 45637, 9156729863

    **************************************************************my_data(table)**********
    try to insert into table below...

    Name, ID, last_name, add, PIN. Mob

    *********************************************

    Let me know if you need anything else... :))

    Hey nanny.

    In fact, in SQL Developer, you can open a connection to the target schema, right-click on the Tables node in the Navigator tree, select import the data, then use the data import wizard. It is extremely flexible. Looks like you have a file of comma-separated variables, so if you select Format: csv and import method: Insert it will probably work fine.

    To minimize the risk of errors during import, choose a limit value of preview so that the wizard can review the data type and the size of all columns in several lines of data as possible, and then examine the size/type of data for each column on the next page of the wizard and replace if necessary. For date columns, it is also important to choose the appropriate format mask.

    Hope this helps,
    Gary
    SQL development team

  • How to display the Date Predefault time

    Hi friends,

    How to display the date in the field to date through sctipting by default I have a requirementy to display the date field as the next day's date with timestamp from 09:00 (15/02/2010-09:00) data type as the field & column is UTC_datetime.please help I get.


    Siebel bee

    Take a look at the function today(), TimeStamp() and ToChar()

    You should be able todo with something similar to this:

    Expr: "ToChar (TimeStamp (), 'MM') + ' / ' + ToChar (TimeStamp (), 'DD') + ' / ' + ToChar (TimeStamp (), 'YYYY') + ' ' + ToChar (TimeStamp (+(1/24), 'HH')) + ': 00:00.

    as a value before failure.

  • Anyone know how to check the date of warranty until when?

    Anyone know how to check the date of warranty until when?

    https://checkcoverage.Apple.com/Jo/en/;JSESSIONID=9pJ0X9pFPJtNg3c44yDGCvk9pVpt5l QSgn4B60y4Skv1WfmnqMkF!-1840326800

  • How to set the date and time on my HP Officejet pro 8600 more?

    How to set the date and time on my HP officejet pro 8600 more?  It just on a printed journal Jan-oo-oo fax shows 00:00 AM.  There are no instructions on how to change this.  I need proof that I sent a fax to a certain date and time.  Help, please.  Thank you

    Hello

    Below are the steps to set the Date and time for your device:

    1. On the Control Panel, press the right arrow key ( ), press Setup ( ).

  • Camileo S20 - How to display the date and time

    Hi, all. I got as Christmas present the Camileo S20, and I am not able to view the date and time in the video. In the manual is no reference on this subject, only how to set the date and time. But what is the intention to set the date and time in the camera, if it is not possible to display video?

    Hello

    Have you checked the user manual of your TV cam?

    If it of possible to display the data and the time you can find in your user manual how to do this. It always interesting to read ;) s

  • How to reset the data counter without resetting the phone

    How to reset the data counter each month so that I can control my data counter with our reset the phone (or) without using factory data reset.

    Thanks for the reply much appreciated.

    Parameters

    Data Manager

    Press the lower left key

    Reset the data counter

  • How to save the data in table 1 d to Excel in continuous

    Mr President.

    How to save the data in table 1 d to Excel at all times, so that all the data of the first scan must be placed first thought and all the data from the second analysis must be placed on the second Board and continue on the street...

    Sy@m...

    Hi Sy@m

    Here is a vi that might give you a few ideas to try:

  • How to read the date and time of a file by labview information

    How to read the date and time of a file by labview information? for example, time created and updated time.

    The similar question had already spoken here (this is the old thread but still seems topical):

    http://forums.NI.com/T5/LabVIEW/file-date-created/TD-p/109836

  • How to analyze the data of the cDAQ and Signal Express, especially after analysis?

    In the first series of tests of my instrument, it took longer than expected for the race.  Thus, the data was saved in 6 days.  The file is too large for export to Excel.  At the beginning of the project, I was as ignorant as I could go ahead and add analysis and the scaling of measures.  By the scaling, I mean my data of switching current dew points or whatever it is that I record.

    How to evolve the data to read the output data as expected 4mA = point of dew of-20 C or 0 PSIG?  Can I pre program this to be recognized for each event?

    For real analysis I am doing – I would first analyze the data I recorded and choose different points to send to Excel to graph and analyze.  Is this possible?

    Secondly, I would like to know how to scale and analyze my data in the project without having to do this later analysis in the future?

    I have a cDAQ-9172 with LabVIEW signal Express 3.0 that uses four modules - 9211 2 modules of thermocouple, my 4-20 1-9201 module +/-10V module and 1-9203.

    Thank you for any assistance.

    Hi Patricia,

    "' You can do this by adding a step Load/Save signals ' analog '.  I hope this helps!

Maybe you are looking for