The combination of two columns in a single

Hi guys,.

Is it possible for a query to combine two columns into one? For example, lets say I have the following query:

SELECT ID, FIRST_NAME, LAST_NAME
EMPLOYEES

I want the output to have two columns: one that contains the ID and the other containing name followed by a space followed by LAST_NAME. I know how to do this outside the query using coldfusion, but it save me a lot of work if there is some way that the query could do for me.

Yes but the operand of concatenation varies somewhat from a database
management system to the other.

In Oracle, it would look this IIRC.

SELECT ID, FIRST_NAME. ' ' || LAST_NAME AS FULL_NAME
EMPLOYEES

Tags: ColdFusion

Similar Questions

  • SELECT with the combination of two columns query

    I need the research to write a nested select statement that would achieve the following.
    Support I have a table as follows
    TestTable
    Name: Age: country
    Test1: 10: USA
    Test2: 11: us.
    Test3: 12: us.
    Test4: 11: Canada
    Test5: 12: Canada

    Now, I want to select in the table above gives the following information.
    Get all the names of people who do not belong to this combination (10:USA, 11:Canada, 12:Canada). The list can be huge.
    The result should be
    Test1:10:USA
    Test1:12:USA

    If it was a combination, I can write
    Select * from TestTable
    the age where <>10 and <>country Canada

    Also, I can also do
    Select * from TestTable
    the age where NOT IN (10,11) and country NOT IN (USA, COUNTRY)
    But I do have that he would give me a correct result.

    sush_msn wrote:
    Is there a way I can move the age and the country as a list on the query?

    You asked the right question.

    Three things you need to know:

    (1) your test data cover all combinations. This is the most comprehensive test data:

    create table test_table1 as
    WITH AGES AS (
      SELECT LEVEL+10 AGE FROM DUAL CONNECT BY LEVEL <= 3
    ), COUNTRIES AS (
      SELECT 'USA' COUNTRY FROM DUAL
      UNION ALL
      SELECT 'CANADA' COUNTRY FROM DUAL
    )
    SELECT 'Test' || ROWNUM NAME, AGE, COUNTRY FROM AGES, COUNTRIES;
    
    NAME                                                AGE COUNTRY
    -------------------------------------------- ---------- -------
    Test1                                                11 USA
    Test2                                                11 CANADA
    Test3                                                12 USA
    Test4                                                12 CANADA
    Test5                                                13 USA
    Test6                                                13 CANADA
    

    (2) now, here's the answer to your question. You can go back two or more values in an expression by putting parentheses around them.

    SELECT * FROM TEST_TABLE1
    WHERE (AGE, COUNTRY) NOT IN (
      (11, 'USA'),
      (12, 'CANADA')
    );
    
    NAME                                                AGE COUNTRY
    -------------------------------------------- ---------- -------
    Test2                                                11 CANADA
    Test3                                                12 USA
    Test5                                                13 USA
    Test6                                                13 CANADA
    

    That's what made the Etbin above, but he used a select instead of a list of values.

    (3) can AGE or COUNTRY ever be NULL? You want to return the records that have NULL values in them? If so, you must use NOT EXISTS instead of NO po WARNING: Etbin code needs a bit of change: "where (age, country) = (t.age, t.country)" should be "where (age, country) = ((t.age, t.country)) '. You must always additional brackets on the right side.

  • How can I create a constraint on the combination of four columns...

    Dear Guru,

    I have a question... I created the table with columns like "CCode', 'Size1', 'Size2', 'Sch1', 'Sch2', 'Description', 'CCdate '.

    Here I wanted to create a unique constraint on the combination of four columns "CCode', 'Size1', 'Size2', 'Sch1', 'Sch2.

    My requirement is that I don't want to allow duplicate records in the table for the four columns only.

    for example: "CC123", 10, 25, S110, S250,.

    If the new record comes with the same data. Then, I do not want to insert this record.i want to get a constraint voilated error.

    How can I create a constraint on the combination of four columns...

    Pls help me on this issue...

    Kind regards

    Shitab...

    I suggested already here the syntax,

    ALTER table your_table

    Add constraint cons_name unique (col1, col2, col3, col4, col5);

    And don't call me 'Sir '.

    See you soon!

  • Starting from two data tables, how do you get the values in two columns using values in a column (values get col. If col. A is not null values and get the pass. B if col. A is null)?

    Two tables provided, how you retrieve the values in two columns using values in a column (the pass get values. If col. A is not null values and get the pass. B if col. A is null)?

    Guessing

    Select nvl (x.col_a, y.col_b) the_column

    from table_1 x,.

    table_2 y

    where x.pk = y.pk

    Concerning

    Etbin

  • Single line based on two columns and a single column

    Dear members,

    I have a table that contains duplicate rows, for which a request should be able to extract the unique row in the table. Here the unique is not based on a single column, but it should be in two columns and also check on the uniqueness on a column.

    create table addr (varchar2 (10) firstname, lastname varchar2 (10), area varchar2 (3));

    insert into values addr ('bob', 'james', 1');
    insert into values addr ('bob', 'james', 1');

    insert into values addr ('harry', 'bert', ' 1');
    insert into values addr ('jimmy', 'bert', ' 1');

    insert into values addr ('sam', 'mac', '1');
    insert into values addr ('sam', 'Knight', '1');

    insert into values addr ('tom', 'sand', '1');
    insert into values addr ("cat", "mud", "1");


    The query output must contain 3 lines.

    Bob - james
    Harry - bert or jimmy - bert [or the other of them], but not both
    -Mac or sam - Sam Knight [or the other of them], but not both
    Tom - sand
    Cat - mud

    SELECT firstname, lastname as total area WHERE addr = '1' GROUP by firstname, lastname; It takes no duplication of single column...

    Any suggestions...
    SQL> with t_data
    as
    (
    select 'bob' as firstname, 'james' as lastname, '1' as area from dual union all
    select 'bob', 'james', '1' from dual union all
    select 'harry', 'bert', '1' from dual union all
    select 'jimmy', 'bert', '1' from dual union all
    select 'sam', 'mac', '1' from dual union all
    select 'sam', 'knight', '1' from dual union all
    select 'tom', 'sand', '1' from dual union all
    select 'cat', 'mud', '1' from dual
    )
    SELECT
            firstname,
            lastname,
            area
    FROM
            (
                    SELECT
                            t.*,
                            row_number() over(partition BY firstname order by 1) rn,
                            row_number() over(partition BY lastname order by 1) rn1
                    FROM
                            t_data t
            )
    WHERE
            rn     = 1
    AND rn1 =1 ;  
    
    FIRSTNAME       LASTNAME        AREA
    --------------- --------------- ----------
    bob             james           1
    cat             mud             1
    jimmy           bert            1
    sam             knight          1
    tom             sand            1
    
    SQL>
    
  • Check the values in two columns, in the affirmative, then generate an error

    Oracle 10g version

    Hi gurus

    I'm test1 table and it contains several columns, my requirement I want to create some sort of conditions or constraints before inserting data into test1, it will check that application_id or APPLICATION_TYPE_CD contains no values in the two columns...

    I appreciate your advice. Thank you

    / / DESC test1

    APPLICATION_ID NUMBER (10)

    DATE OF APPLICATION_DT

    APPLICATION_TYPE_CD VARCHAR2 (10)

    DATE OF CREATED_DT

    Concerning

    MIT

    You need a check as a constraint:

    ALTER table test1 add constraint only_one

    check ((application_id n'est pas null et application_type_cd est null) or)

    (application_id is null and application_type_cd is not null))

    John

  • OBIEE: Cannot do the subtraction between two columns

    I would like to see the difference between the expenses of the customer in the current from the previous period. Thus, each row contains data from a single client. And my first field (column A) lists the customer spending in the current field of the era and the second (column B) for the previous period. I tried to calculate the difference in my third field (column C).

    However, given that some of the cells in column A are "null", the respective cells in column C appeared also as "null".
    I tried to convert the column A 0 help ifnull null cells. But the respective cells in column C may not always do the subtraction.

    Help, please! Thanks in advance.

    Hello

    In the column C set Ifnull(Col A) - Ifnull(Col B) try this. I tried and it works for me.

  • Splits the string into two columns

    Can someone please help me the following

    I want to divide into two columns URL and ID /cfd/abc.html,/night/aaa/Page1,/can/MLP/Page2|107

    Result must be

    Temporary table
    < font color = "red" > URL < / police > < font color = 'blue' > ID < / make >

    < font color = "red" > /cfd/abc.html < / police > < font color = "blue" > 107 < / make >

    < font color = "red" > / night/aaa/page 1 < / police > < font color = "blue" > 107 < / make >

    < font color = "red" > / can/MLP/Page2 < / police > < font color = "blue" > 107 < / make >


    There can be N number of comma separated URLs, but there will be only 1 separate ID which is the vertical bar (|)

    Try this,

    SQL> WITH T
      2       AS (SELECT  '/cfd/abc.html,/night/aaa/Page1,/can/MLP/Page2|107 ' str FROM DUAL UNION ALL
      3           SELECT  '/cfd/def.html,/bbbb/bbbb/Page1,/lll/MLP/Page3|108 ' str FROM DUAL)
      4  SELECT REGEXP_SUBSTR ( str, '[^,|]+', 1, lvl) URL,
      5         REGEXP_SUBSTR ( str, '[^|]+', 1, 2) ID
      6    FROM T,
      7         (SELECT LEVEL lvl
      8            FROM (SELECT MAX (LENGTH (REGEXP_REPLACE ( str, '[^,]'))) mx FROM T)
      9          CONNECT BY LEVEL <= mx + 1)
     10   WHERE Lvl - 1 <= LENGTH (REGEXP_REPLACE ( str, '[^,]+'))
     11   order by id,lvl;
    
    URL                                                ID
    -------------------------------------------------- -------------------------------------------------
    /cfd/abc.html                                      107
    /night/aaa/Page1                                   107
    /can/MLP/Page2                                     107
    /cfd/def.html                                      108
    /bbbb/bbbb/Page1                                   108
    /lll/MLP/Page3                                     108
    
    6 rows selected.
    
    SQL> 
    

    G.

  • Dynamics as the sum of two columns in another

    Hi all
    I'm new with apex, and I had a problem I think its simple but I can't do it :)
    problem is, I have a table with column 3 I need dynamic action on the value of change in two columns to summarize this in a 3rd.
    So I can be able to add 5 rows calculate the columns in row and submit them.
    X Y Z
    1 2 3
    2 2 4
    5 5 10
    Send

    Thank yor occasionally you

    Check this thread column calculated in table form. The same problem is discussed here.

  • Load the rule with the data in two columns.

    I have a SQL Interface as the source of data for my rule to load but I have two columns of data, it is possible to load them into the same rule of load?

    Published by: user5170363 on June 4, 2010 18:51

    Published by: user5170363 on June 4, 2010 19:04

    This is in addition to what Glenn says.
    Generally, we will have two types of data files.
    If we have five dimensions.

    (1) in the first five columns of data files is the names of the members and the last column data.
    The mapping is like this:
    column contains the names of the members the deposited property is a corresponding dimension name
    column contains numbers the area of the given property.

    (1) in the foucolumns files first is the member names and you have one or more columns of data
    The mapping is like this:
    column contains the names of the members the deposited property is a corresponding dimension name
    column contains numbers the property field is the names of the members of the dimension remaining problems (level 0).

    Note: To provide the missing information from the dimension, you can use header definition in the rules file.

  • Impossible to enter the title of the document when you use the model of two columns left navigation

    I use DW 8, two columns left navigation model to rework my company Web site. My level of experience is probably beginner (known in Web design database and update existing sites; minimal associated style sheets).

    From the model mentioned, I created a template for my business site and saved it as "template.dwt." Then, I created a new page using this template. I click in "Title" and type the title of the page, but it defaults to "untitled document".

    I tried to follow the message thread of beachnut2 to "Model has locked the title of the document", but got lost. I followed the advice of Murray "create a new page. Save it as a template with FILE | Save as
    Model. Look at the code. The code on this new model, I created is as follows:

    <! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional / / IN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
    "< html xmlns =" http://www.w3.org/1999/xhtml "> "
    < head >
    < meta http-equiv = "Content-Type" content = text/html"; charset = iso-8859-1 "/ >"
    < title > Untitled Document < /title >
    < / head >

    My model based on the two-column template is as follows:

    <! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional / / IN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
    "< html xmlns =" http://www.w3.org/1999/xhtml "> <! - DW6->"
    < head >
    <!-copyright 2005 Macromedia, Inc. All rights reserved. ->
    < meta http-equiv = "Content-Type" content = text/html"; charset = iso-8859-1 "/ >"
    < title > Untitled Document < /title >
    < link rel = "stylesheet" href = "2col_leftNav.css" type = "text/css" / > < / head > "

    If I do the above tag looks like the blank template, I created, I lose the stylesheet link before the < / head > tag.

    Any suggestions on how I can fix this?

    Thank you for your quick response. I thought I had followed your instructions by creating a new document and save it as a template. The mistake I made was selecting a new basic HTML when I was selecting the new model basic HTML. This time, I got the correct tags, the copied on my model and it works now. Thank you for your help.

  • Review of the show in two columns

    Apex 3.2

    I have a report and she 22 rows and 1 column.

    For the moment, I shows the first 15 lines and then you must be paginated.

    The report will not grow much, maybe to 30 rows.

    Is there a way to display the first 15 lines in column 1 and the second in another column, side by side etc.

    Gus

    Well Yes, you're right, that's enough undistinct.

    The following should work better:

    with base as

    (select shortdescr, no_lig - col * 16 no_lig, Col.

    from (select gwh.shortdescr, rownum, floor(rownum / 16) col no_lig

    to select (separate gwh.shortdescr

    of udm_wh gwh, udm_lde lde

    where lde.ldeid = gwh.ldeid

    and lde.ldekey = 'MCDGBL')))

    Select t1.shortdescr, t2.shortdescr

    from (select * base where col = 0) t1.

    (select * base where col = 1) t2

    where t1.row_num = t2.row_num (+)

    Greetings

    Chris

  • concatenate the strings from a column into a single row?

    How to concatenate strings from a column into a single line?

    Color
    ------
    Red
    Orange
    Blue
    Green

    And return a set of results as follows:

    Colors
    -------------------------
    Red, orange, blue, green

    Various ways can be found here:
    http://www.Oracle-base.com/articles/10G/StringAggregationTechniques.php

  • The combination of two projects

    I have a need to import a single .cp file to .cp file. Merger mainly to projects in one. Is this possible in a way that will allow me to have a single consolidated project that I'll be able to change end-to-end?

    Thank you
    Jay

    Welcome to our community, Jay

    Yes, it is possible to combine projects. Remember that projects have some importance from the perspective of 'number of total slides' which is considered to be best practice. Number of magick is usually between 50-65 (give or take and subjected to all kinds of interpretation). If your new handset project will be way beyond that, you might want to reconsider the approach.

    To combine, click file > import > slides/objects and refer her to the other project.

    Also, it will keep things more simple if you have the two projects of the same size.

    See you soon... Rick

  • Results the combination of two different "reports."

    Not sure if what I have to do is possible in the analytical framework, but maybe the experts can guide me.

    Here's the situation:

    In the box account, there is a field that "connects" account. What I need to do, is to show all accounts and the number of those who bind together. Here is a Visual... (with a few columns)

    Data

    Column1 Column2 Column3 column4 column 5... etc.
    Yes {color: #0000ff} 12345 {color}
    AccountB {color: #0000ff} 12345 {color} B
    AccountC {color: #0000ff} 12345 {color} C
    AccountD {color: #339966} 99999 {color} D
    AccountE {color: #339966} 99999 {color} E
    AccountF {color: #339966} 99999 {color} F
    AccountG {color: #339966} 99999 {color} G

    I need to show

    Column1 Column2 Column3 column 4 (which is a count of all those who have the same column 2)
    Yes 12345 3
    AccountB 12345 3
    AccountC 12345 3
    AccountD 4 99999
    AccountE 99999 4
    AccountF 4 99999
    AccountG 4 99999


    I can make a PivotTable and get

    3 12345
    4 99999

    But don't know if I can take this value in a single report.

    Certainly can dump the data to excel and 'join' the two, I wanted to see if this could be done within OnDemand.

    Any suggestions?

    I think your missing what how you count Column2. It takes (column2 by column2).

    He works at the table and pivot views.

    See you soon

Maybe you are looking for