Select ambiguous column in Sub query

I get an error "ambiguous column" when I question using a sub select. Here's my query:

Select *.
(select
c.custody_id,
c.person_id,
n.first_name,
n.last_name,
z.usms_number,
c.start_date,
c.end_date,
c.district_office_id,
CBC.custody_id,
c.update_date,
c.update_user_id
Guard c,.
custody_booking_pkg_components Radio-Canada,
z_migrate_usms_number z,
district_office do,
District d,
person p,
n name
where
c.person_id = p.person_id and
z.person_id = p.person_id and
z.Ordinal = 1 and
c.custody_id = cbc.custody_id (+) and
p.name_id = n.name_id and
do.district_id = d.district_id and
c.district_office_id = do.district_office_id and
d.district_id = 99 by c.update_date desc order)
where rownum < = 10;

I understand why "ambiguous column" average error, but I don't see which column is ambiguous. I ran the select sub by itself and it works correctly, but when combined with the external selection it fails.

Hello

You have two columns called custody_id.
It is normal to have names duplicated in a query, but not in a table or view (and which includes a view online, you have).

Type a unique name for each column.

Tags: Database

Similar Questions

  • Need help to write a sub query

    Our environment - Oracle 10 g

    Hi all
    Need help to write a sub query to reach him here are examples of data using which iam trying to replace the value column in the table based on two other columns in the same table

    Examples of data

    ClaimNo flag LineNo Procedurecode
    100 01 N MN4567
    100 02 Y 7863
    100 03 N MN8976
    100 04 Y 9000
    101 01 Y 8954
    101 02 N MN6754
    101 03 N MN7654
    101 04 Y 8976
    102 01 Y 1234
    102 02 Y 2345
    102 03 Y 3456
    102 03 Y 4567

    Each column of ClaimNo has several rows of data. But if column procedurecode for a claimNo starts with MN then all values associated with the claimno for the flag column should replace N

    If the data must become like below

    ClaimNo flag LineNo Procedurecode
    100 01 N MN4567
    100 02 N 7863
    100 03 N MN8976
    100 04 N 9000
    101 01 N 8954
    101 02 N MN6754
    101 03 N MN7654
    101 04 N 8976
    102 01 Y 1234
    102 02 Y 2345
    102 03 Y 3456
    102 03 Y 4567


    Thank you

    See the example:

    with t as (
                  select 100 ClaimNo, '01' LineNo, 'N' Flag, 'MN4567' Procedurecode from dual
        union all select 100, '02', 'Y', '7863' from dual
        union all select 100, '03', 'N', 'MN8976' from dual
        union all select 100, '04', 'Y', '9000' from dual
        union all select 101, '01', 'Y', '8954' from dual
        union all select 101, '02', 'N', 'MN6754' from dual
        union all select 101, '03', 'N', 'MN7654' from dual
        union all select 101, '04', 'Y', '8976' from dual
        union all select 102, '01', 'Y', '1234' from dual
        union all select 102, '02', 'Y', '2345' from dual
        union all select 102, '03', 'Y', '3456' from dual
        union all select 102, '03', 'Y', '4567' from dual
    )
    select
        claimno,
        lineno,
        flag,
        case
          when count(decode(substr(procedurecode,1,2),'MN',1)) over(partition by claimno)>0
            then 'N'
          else flag
        end new_flag,
        procedurecode
    from t
    

    Kind regards
    Sayan M.

  • Order By in the Sub query

    We cannot use ORDER BY in the Sub query.
    select * from emp where emp_no in (select emp_id from dept order by dept_no )
    Get the below error
    ORA-00907: missing right parenthesis

    Hello

    user13024762 wrote:
    To get the number of EMP table for maximum number of dept dept

    If this is what you want, then do something like this:

    select  *
    from      emp
    where      emp_no in (
                          select    MAX (emp_no) KEEP (DENSE_RANK LAST ORDER BY dept_no NULLS FIRST)
                   from      dept
                )
    ;
    

    or maybe

    select  *
    from      emp
    where      emp_no  = (
                          select    emp_no
                   from      dept
                   where     dept_no = (
                                                    SELECT  MAX (dept_no)
                                 FROM    dept
                                                 )
                )
    ;
    

    Depending on what you want in the case of a tie.

    select * from emp where emp_no in (select emp_no from dept where rownum =1 order by dept_no desc)
    

    The subquery that you posted above does not necessarily return the line containing the largest dept_no, since ROWNUM is affected before ORDER BY is done.

    I hope that answers your question.
    If not, post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) for all tables and also post the results desired from these data.
    Explain how you get these results from these data.

  • How to get the value of a column in sql query?

    Hi, anyone knows how to get the value of a column in sql query?

    Here is my code, the value must be 1350079224397 in my PB, but I get 0

    QString query ("SELECT version FROM db_version");

    QVariant result = sda.execute (query);
    QVariantMap versionMap = result.toList () such () .toMap ();
    If (! versionMap.IsEmpty ())
    {
    qDebug()<"Version: "=""><>
    }

    OK, I have the solution

    QString query ("SELECT version as version FROM db_version");

  • Select the column name when the value = something

    Is there a way to select the column name when there is a specific value in it?

    As follows:

    create table (abc123)

    COLUMN1 VARCHAR2 (50).

    COLUMN2 VARCHAR2 (50).

    Column3 varchar2 (50)

    );

    insert into abc123 values ('yes', 'Yes', 'No');

    insert into abc123 values ('no', 'Yes', 'No');

    INSERT INTO ABC123 VALUES ('no ',' no', 'No');

    insert into abc123 values ('yes', 'Yes', 'Yes');

    SELECT CASE WHEN COLUMN1 = 'Yes' THEN - the name of the column would be here somehow?

    WHEN COLUMN2 = 'Yes' THEN - the name of the column would be here somehow?

    WHERE Column3 = 'Yes' THEN - the name of the column would be here somehow?

    Another null

    finish as abc123 columnname

    final results for the just Column1 would be:

    COLUMN1

    NULL VALUE

    NULL VALUE

    COLUMN1

    I'm not sure what I use to get the name of column in there

    Thank you.

    Hello

    708631 wrote:

    Is there a way to select the column name when there is a specific value in it?

    As follows:

    create table (abc123)

    COLUMN1 VARCHAR2 (50).

    COLUMN2 VARCHAR2 (50).

    Column3 varchar2 (50)

    );

    insert into abc123 values ('yes', 'Yes', 'No');

    insert into abc123 values ('no', 'Yes', 'No');

    INSERT INTO ABC123 VALUES ('no ',' no', 'No');

    insert into abc123 values ('yes', 'Yes', 'Yes');

    SELECT CASE WHEN COLUMN1 = 'Yes' THEN - the name of the column would be here somehow?

    WHEN COLUMN2 = 'Yes' THEN - the name of the column would be here somehow?

    WHERE Column3 = 'Yes' THEN - the name of the column would be here somehow?

    Another null

    finish as abc123 columnname

    final results for the just Column1 would be:

    COLUMN1

    NULL VALUE

    NULL VALUE

    COLUMN1

    I'm not sure what I use to get the name of column in there

    Thank you.

    Thanks for posting the CREATE TABLE and INSERT for the sample data.

    Don't forget to post the exact results you want from these sample data.  If the results depend on the parameters you want to pass a run time, then give a few different examples, with the the desired results of each.

    You can hardcode the values you want, such as the column names in a query.  For example:

    SELECT CASE WHEN column1 = 'Yes' THEN 'Column1' END like y1

    CASE WHEN column2 = 'Yes' THEN 'Column2' END like y2

    CASE WHEN Column3 = 'Yes' THEN 'Column2' END like y3

    , a. *-If wanted

    Of abc123 one

    ;

  • 2nd selection list column

    Dear Sir

    Not sure if possible, I found 1 result of valid research.
    He spoke of the concatting columns.

    What I want is to select 2 columns in the select list 1.
    He said that it would be possible, by the following code
     select column1||' '||column2,
    from table1
    but I have an error: wrong number of columns selected in the SQL LOV query. See the examples of valid conclusions
    is this impossible, or am I wrong?

    LOV must have 2 columns. A screen and back.

    select product_name d, product_id r
    from product
    

    Your of returns only one. If your display and back are the same then try this:

    select column1||' '||column2 d,
    column1||' '||column2 r
    from table1
    
  • Select the columns not in the group by clause

    Hello

    My version of DB is 10.0.2

    I have query, where in I need to select two columns more but that should not be part of the group by Clause.

    Does perform a work around?
    SELECT  F.custnum, 
      V.Import_date,
     -- F.ErledigtMM,F.ErledigtGrundMM, (Columns to be selected additionally)
      nvl(sum(nvl(round(V.VerAuf16/1000,2), 0)  +nvl(round(V.VerAuf17/1000,2), 0)  + nvl(round(V.VerAuf18/1000,2), 0)  + nvl(round(V.VerAuf19/1000,2), 0)  + nvl(round(V.VerAuf20/1000,2), 0)  + nvl(round(V.VerAufKAPUn/1000,2), 0)  + nvl(round(V.VerAufKAPVz/1000,2), 0) ), 0)  Mandantenforderung,
      nvl(sum(nvl(round(V.VerAuf4/1000,2), 0) ), 0) Inkassokosten,
      nvl(sum(nvl(round(V.VerAuf5/1000,2), 0) ), 0) KontoFuehrungsgebuehren,
      nvl(sum(nvl(round(V.VerAuf1/1000,2), 0)  + nvl(round(V.VerAuf2/1000,2), 0) ), 0)  Verwertungskosten,
      nvl(sum(nvl(round(V.VerAuf10/1000,2), 0)  + nvl(round(V.VerAuf8/1000,2), 0) + nvl(round(V.VerAuf9/1000,2), 0) ), 0)  Barauslagen,
      nvl(sum(nvl(round(V.VerAuf13/1000,2), 0)  + nvl(round(V.VerAuf14/1000,2), 0) + nvl(round(V.VerAuf15/1000,2), 0)  + nvl(round(V.VerAuf6/1000,2), 0) ),0)  Gerichtskosten,
      nvl(sum(nvl(round(V.VerAuf11/1000,2), 0)  + nvl(round(V.VerAuf12/1000,2), 0)  + nvl(round(V.VerAuf7/1000,2), 0) ), 0) RAKosten,
      TO_CHAR(F.Created_Date,'MM.YYYY') Created_Date_MM ,
      TO_CHAR(F.Created_Date,'YYYY') Created_Date_MMRRRR
    FROM FACM F, VA V 
       WHERE  F.custnum =  DECODE(0,0,F.custnum,0) AND
      F.accnum = V.accnum 
      GROUP BY F.custnum, V.Import_date,TO_CHAR(F.Created_Date,'MM.YYYY') ,TO_CHAR(F.Created_Date,'YYYY'))

    Hello

    Here's what I suggest:

    select
    a.custnum,
    a.import_date,
    b.ErledigtMM,
    b.ErledigtGrundMM,
    a.Mandantenforderung,
    a.Inkassokosten,
    a.KontoFuehrungsgebuehren,
    a.Verwertungskosten,
    a.Barauslagen,
    a.Gerichtskosten,
    a.RAKosten,
    a.Created_Date_MM ,
    a.Created_Date_MMRRRR
    from (
    SELECT  F.custnum,
      V.Import_date,
      nvl(sum(nvl(round(V.VerAuf16/1000,2), 0)  +nvl(round(V.VerAuf17/1000,2), 0)  + nvl(round(V.VerAuf18/1000,2), 0)  + nvl(round(V.VerAuf19/1000,2), 0)  + nvl(round(V.VerAuf20/1000,2), 0)  + nvl(round(V.VerAufKAPUn/1000,2), 0)  + nvl(round(V.VerAufKAPVz/1000,2), 0) ), 0)  Mandantenforderung,
      nvl(sum(nvl(round(V.VerAuf4/1000,2), 0) ), 0) Inkassokosten,
      nvl(sum(nvl(round(V.VerAuf5/1000,2), 0) ), 0) KontoFuehrungsgebuehren,
      nvl(sum(nvl(round(V.VerAuf1/1000,2), 0)  + nvl(round(V.VerAuf2/1000,2), 0) ), 0)  Verwertungskosten,
      nvl(sum(nvl(round(V.VerAuf10/1000,2), 0)  + nvl(round(V.VerAuf8/1000,2), 0) + nvl(round(V.VerAuf9/1000,2), 0) ), 0)  Barauslagen,
      nvl(sum(nvl(round(V.VerAuf13/1000,2), 0)  + nvl(round(V.VerAuf14/1000,2), 0) + nvl(round(V.VerAuf15/1000,2), 0)  + nvl(round(V.VerAuf6/1000,2), 0) ),0)  Gerichtskosten,
      nvl(sum(nvl(round(V.VerAuf11/1000,2), 0)  + nvl(round(V.VerAuf12/1000,2), 0)  + nvl(round(V.VerAuf7/1000,2), 0) ), 0) RAKosten,
      TO_CHAR(F.Created_Date,'MM.YYYY') Created_Date_MM ,
      TO_CHAR(F.Created_Date,'YYYY') Created_Date_MMRRRR
    FROM FACM F, VA V
       WHERE  F.custnum =  DECODE(0,0,F.custnum,0) AND
      F.accnum = V.accnum
      GROUP BY F.custnum, V.Import_date,TO_CHAR(F.Created_Date,'MM.YYYY') ,TO_CHAR(F.Created_Date,'YYYY'))
    ) a,
    FACM b
    where b.custnum = a.custnum 
    

    By the way

    WHERE  F.custnum =  DECODE(0,0,F.custnum,0) AND F.accnum = V.accnum
    

    can be translated into

    WHERE F.accnum = V.accnum
    

    because

    F.custnum =  DECODE(0,0,F.custnum,0)
    

    is always true
    because

    DECODE(0,0,F.custnum,0)
    

    means

    if 0=0 then F.custnum else 0
    
  • How to know what sub query returns multiple rows

    Hi all

    Someone can give me hints, how to know what sub query returns many rows in the following query.
    /* Formatted on 2011/05/17 19:22 (Formatter Plus v4.8.8) */
    SELECT a.*, ROWNUM AS rnm
      FROM (SELECT DISTINCT '1' AS "Page View", ou.org_unit_name AS "Org",
                            prxm.mbr_idntfr AS "Beneficiary ID",
                               md.last_name
                            || ', '
                            || md.first_name AS "Beneficiary Name",
                            pci.idntfr AS "Tracking No.",
                            TO_CHAR (TRUNC (req.pa_rqst_date),
                                     'MM/dd/yyyy'
                                    ) AS "Request Date",
                            sts.status_name AS "Status",
                            req.pa_rqst_sid AS "Request #",
                            prxm.mbr_sid AS "Mbr_sid",
                            TO_CHAR
                                  (TRUNC (req.pa_revision_date),
                                   'MM/dd/yyyy'
                                  ) AS "Last Updated",
                            TO_CHAR (psd.TO_DATE, 'MM/dd/yyyy') AS "TO_DATE",
                            prxpl.prvdr_lctn_iid AS "PRVDR_LCTN_IID",
                            pd.prvdr_sid AS "PRVDR_SID", 'Y' AS "State View",
                            DECODE
                               ((SELECT DISTINCT pd.national_prvdr_idntfr
                                            FROM pa_request_x_provider_location prxplo
                                           WHERE prxplo.pa_rqst_sid =
                                                                   req.pa_rqst_sid
                                             AND prxplo.oprtnl_flag = 'A'
                                             AND prxplo.pa_prvdr_type_lkpcd = 'RR'),
                                0, (SELECT prxplo.prvdr_lctn_idntfr
                                      FROM pa_request_x_provider_location prxplo
                                     WHERE prxplo.pa_rqst_sid = req.pa_rqst_sid
                                       AND prxplo.oprtnl_flag = 'A'
                                       AND prxplo.pa_prvdr_type_lkpcd = 'RR'),
                                NULL, (SELECT prxplo.prvdr_lctn_idntfr
                                         FROM pa_request_x_provider_location prxplo
                                        WHERE prxplo.pa_rqst_sid = req.pa_rqst_sid
                                          AND prxplo.oprtnl_flag = 'A'
                                          AND prxplo.pa_prvdr_type_lkpcd = 'RR'),
                                (SELECT DISTINCT pd.national_prvdr_idntfr
                                            FROM pa_request_x_provider_location prxplo
                                           WHERE prxplo.pa_rqst_sid =
                                                                   req.pa_rqst_sid
                                             AND prxplo.oprtnl_flag = 'A'
                                             AND prxplo.pa_prvdr_type_lkpcd = 'RR')
                               ) AS "NPI/ID",
                            DECODE
                               ((SELECT pd.org_bsns_name
                                   FROM pa_request_x_provider_location prxplo
                                  WHERE prxplo.pa_rqst_sid = req.pa_rqst_sid
                                    AND prxplo.oprtnl_flag = 'A'
                                    AND prxplo.pa_prvdr_type_lkpcd = 'RR'),
                                NULL, (SELECT    pd.last_name
                                              || ', '
                                              || pd.first_name
                                              || ' '
                                              || pd.middle_name
                                         FROM pa_request_x_provider_location prxplo
                                        WHERE prxplo.pa_rqst_sid = req.pa_rqst_sid
                                          AND prxplo.oprtnl_flag = 'A'
                                          AND prxplo.pa_prvdr_type_lkpcd = 'RR'),
                                (SELECT pd.org_bsns_name
                                   FROM pa_request_x_provider_location prxplo
                                  WHERE prxplo.pa_rqst_sid = req.pa_rqst_sid
                                    AND prxplo.oprtnl_flag = 'A'
                                    AND prxplo.pa_prvdr_type_lkpcd = 'RR')
                               ) AS "Prvdr Name",
                            TO_CHAR (psd.from_date,
                                     'MM/dd/yyyy'
                                    ) AS "Srvc From Date",
                            TO_CHAR (req.validity_start_date,
                                     'MM/DD/YYYY'
                                    ) AS "Due Date",
                            (fn_get_busniess_days (TRUNC (req.validity_start_date))
                            ) AS "Days<br>Left",
                            req.pa_mode_type_lkpcd AS "Source",
                            TO_CHAR (TRUNC (wmdtl.rtng_date),
                                     'MM/dd/yyyy'
                                    ) AS "Assigned On",
                            NVL (wmdtl.assigned_to_user_name,
                                 'Not Assigned'
                                ) AS "Assigned To",
                            req.org_unit_sid AS "OrgUnitSid",
                            TO_CHAR
                                 (wmdtl.modified_date,
                                  'MM/dd/yyyy hh24:mi:ss'
                                 ) AS "WTRD_MODIFIED_DATE",
                            TO_CHAR (wmdtl.rtng_date,
                                     'MM/dd/yyyy'
                                    ) AS "WTRD_RTNG_DATE",
                            req.status_cid AS "PA_STATUS_CID",
                            TO_CHAR (req.modified_date,
                                     'MM/dd/yyyy'
                                    ) AS "PA_REQ_MODIFIED_DATE",
                            prs.state_pa_srvc_type_code
                                                     AS "STATE_PA_SRVC_TYPE_CODE",
                            wmdtl.wm_pa_task_rtng_dtl_sid
                                                        AS "WM_TASK_RTNG_DTL_SID",
                            wmdtl.assigned_to_user_acct_sid
                                              AS "WTRD_Assigned_to_user_acct_sid",
                            (fn_get_busniess_days (TRUNC (req.validity_start_date))
                            ) AS "Days<br>LeftSort",
                            wmdtl.assigned_to_org_unit_sid
                                                  AS "WTRD_Assigned_to_OrgUntSid",
                            DECODE
                               ((SELECT COUNT (*)
                                   FROM pa_request_status prs
                                  WHERE prs.pa_rqst_sid = req.pa_rqst_sid
                                    AND prs.status_cid = 5
                                    AND prs.oprtnl_flag = 'I'),
                                0, 'N',
                                'Y'
                               ) AS "SHOW_UTILIZATION"
                       FROM   pa_request req,
                             pa_certification_identifier pci,
                             status sts,
                             pa_request_x_member prxm,
                             wm_pa_task_routing_detail wmdtl,
                             pa_service_date psd,
                             org_unit ou,
                             pa_request_service prs,
                             pa_request_x_provider_location prxpl,
                             provider_location pl,
                             provider_detail pd,
                             provider p,
                             mbr_dmgrphc md
                      WHERE req.oprtnl_flag = 'A'
                        AND req.status_cid NOT IN
                                     (20, 30, 70, 25, 80, 96, 85, 5, 97, 98, 101)
                        AND req.org_unit_sid IN
                               (3057, 3142, 3058, 3143, 3059, 3144, 3060, 3145,
                                3061, 3146, 3062, 3147, 3063, 3148, 3064, 3149,
                                3065, 3150, 3066, 3151, 3067, 3152, 3068, 3153,
                                3069, 3154, 3070, 3155, 3071, 3156, 3072, 3157,
                                3073, 3158, 3074, 3159, 3075, 3160, 3076, 3161,
                                3077, 3162, 3078, 3163, 3079, 3164, 3080, 3165,
                                3081, 3166, 3082, 3167, 3083, 3168, 3084, 3169,
                                3085, 3170, 3086, 3171, 3087, 3172, 3088, 3173,
                                3089, 3174, 3090, 3175, 3091, 3176, 3092, 3177,
                                3093, 3178, 3094, 3179, 3095, 3180, 3096, 3181,
                                3097, 3182, 3098, 3183, 3099, 3184, 3100, 3185,
                                3101, 3186, 3102, 3187, 3103, 3003, 75000104,
                                75000108, 2006, 75000103, 75000102, 75000113,
                                75000111, 75000109, 2001, 2009, 75000105,
                                75000107, 2004, 2010, 2013, 2014, 2005, 2011,
                                75000112, 2002, 1001, 2012, 75000106, 2007,
                                75000101, 2003, 75000110, 2008, 3001, 3002, 3019,
                                3104, 3020, 3105, 3021, 3106, 3022, 3107, 3023,
                                3108, 3024, 3109, 3025, 3110, 3026, 3111, 3027,
                                3112, 3028, 3113, 3029, 3114, 3030, 3115, 3031,
                                3116, 3032, 3117, 3033, 3118, 3034, 3119, 3035,
                                3120, 3036, 3121, 3037, 3122, 3038, 3123, 3039,
                                3124, 3040, 3125, 3041, 3126, 3042, 3127, 3043,
                                3128, 3044, 3129, 3045, 3130, 3046, 3131, 3047,
                                3132, 3048, 3133, 3049, 3134, 3050, 3135, 3051,
                                3136, 3052, 3137, 3053, 3138, 3054, 3139, 3055,
                                3140, 3056, 3141)
                        AND req.pa_rqst_sid = prs.pa_rqst_sid
                        AND prs.oprtnl_flag = 'A'
                        AND prs.pa_rqst_srvc_sid = psd.pa_rqst_srvc_sid
                        AND psd.oprtnl_flag = 'A'
                        AND req.pa_rqst_sid = pci.pa_rqst_sid
                        AND pci.oprtnl_flag = 'A'
                        AND req.pa_rqst_sid = prxm.pa_rqst_sid
                        AND prxm.oprtnl_flag = 'A'
                        AND md.oprtnl_flag = 'A'
                        AND md.status_cid = 2
                        AND TRUNC (SYSDATE) BETWEEN md.from_date AND md.TO_DATE
                        AND prxm.mbr_sid = md.mbr_sid
                        AND ou.org_unit_sid = req.org_unit_sid
                        AND ou.oprtnl_flag = 'A'
                        AND req.pa_rqst_sid = prxpl.pa_rqst_sid
                        AND prxm.pa_rqst_sid = prxpl.pa_rqst_sid
                        AND pci.pa_rqst_sid = prxm.pa_rqst_sid
                        AND pci.pa_rqst_sid = wmdtl.subsystem_task_sid
                        AND pci.pa_rqst_sid = prxpl.pa_rqst_sid
                        AND prxpl.pa_prvdr_type_lkpcd = 'RR'
                        AND prxpl.oprtnl_flag = 'A'
                        AND req.status_cid = sts.status_cid
                        AND sts.status_type_cid = 3
                        AND sts.oprtnl_flag = 'A'
                        AND prxpl.prvdr_lctn_iid = pl.prvdr_lctn_iid
                        AND p.prvdr_sid = pd.prvdr_sid
                        AND p.prvdr_sid = pl.prvdr_sid
                        AND pd.oprtnl_flag = 'A'
                        AND pd.status_cid = 2
                        AND TRUNC (SYSDATE) BETWEEN pd.from_date AND pd.TO_DATE
                        AND wmdtl.subsystem_task_sid = req.pa_rqst_sid
                        AND wmdtl.subsystem_lkpcd = 'PA'
                        AND wmdtl.oprtnl_flag = 'A'
                        AND req.pa_rqst_date > (SYSDATE - 365)
                                       ORDER BY TO_DATE ("Request Date", 'MM/dd/yyyy hh24:mi:ss') DESC,
                            "Beneficiary Name" ASC) a
     WHERE ROWNUM < 102;
    Kind regards
    Prakash P

    Published by: BluShadow on May 17, 2011 15:01
    addition of {noformat}
    {noformat} tags around the code                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                

    3360 wrote:
    See point 9 of this section of the FAQ on how to format the code.

    SQL and PL/SQL FAQ

    I see that you did.

    No, I did. It's pretty easy to change if the code seems formatted anyway below. It's when I go to edit the message and find no sense because it is not formatted in all cases, I despair. {noformat} :) {noformat}

  • Sub query problem

    Hi all

    Problem with sub query.

    Select * from where the team team_id in (team_id region selection);

    If I run the query above is the length, but the problem is that I don't have team_id in the region table. How oracle to run this query. Please explain.

    If I run select region team_id;

    I got error like team_id invalid.


    I'm using the version of oracle 10g.


    Thank you.

    Sunita.

    sunitha2010 wrote:
    Hi all

    Problem with sub query.

    Select * from where the team team_id in (team_id region selection);

    If I run the query above is the length, but the problem is that I don't have team_id in the region table. How oracle to run this query. Please explain.

    Because of the determination of the scope.
    Oracle uses the "team_id" of the outer query.

    If you were to use:

    select * from team  where team_id in (select region.team_id from region);
    

    THEN, you will get an error.

  • Select the column by using Session variables

    I set a session variable to contain the name of a bound column that is the user. Is it possible to use a session variable to select a column in a database table? If so, how? Does need a statement where clause?

    Something like that? :

    < cfquery name = "rsSelectColumn" datasource = 'Test' >
    SELECT column 1, column 2, column 3 is Variable from Session
    OF tbl_data
    < / cfquery >

    Thank you
    Dave

    I think you want to do this, if the value in the session variable is the actual column name:


    SELECT column 1, column 2, #Session Variable # AS Col3
    OF tbl_data

    in this way, you can call any column stored in the session variable, and it will still be usable from the QUERY as COL3 regardless of which column you used.

    If that's what you want to do - it OF as simple as that.

    :-)

    Sometimes we have to think of things too.

  • Regd select the column in the table area

    Hello

    I have a search page... Have used autocustomization to create... This page will be used to query data from a table and then we must also update two fields of results table and save.

    There is a region of results. I've included the multiselect table option that made me select a column as the first column of the table. Also, including a tableaction and a button upate with whom...

    I need to write a handler for the update now... but do not understand all the slect column...

    Whenever a user clicks on the boxes to select specific records and change the fields and click Update to save, how to write code to check whether the checkbox option has been activated or not?


    Please help me as soon as possible...


    Kind regards
    Preeti

    Hello

    Take a Transient attribute tell 'SelectFlag' in view object and to set the Instance of the view and the view attribute
    for multipleselection in the table.

    Now that the update is click on the button:

    If (PageContext.GetParameter ("Update")! = null)
    {
    OAApplicationModule am = pageContext.getApplicationModule (webBean);
    OAViewObject vo = (OAViewObject) am.findViewObject ("projVO1");
    Line [] row = vo.getAllRowsInRange ();
    Loop through lines
    for (int i = 0; i)<>
    {
    Check if checbox is checked or not
    If (line.getAttribute("SelectFlag").toString().equals("Y"))//means checbox is checked for this line.
    {
    write your logic
    }
    }
    }

    Thank you
    Gerard

  • Problems with Sub query

    Hello, I'm looking to create a sub query to display certain information. On the form that the information is entered, the user has the option to enter a phone number extension, as appropriate. If this is the case, I want the phone number to show as 555-867-5309 (x 1234). However, without the problem of controls, the (x) will be displayed without worrying and seems sloppy. Here is the code I have, please notify.

    There will be two places, it will be necessary - for the telephone number of the applicant and the app (SME) contact information manager.

    Thank you.

    select
        pm.pk_proj_master_id "Project Number",
        pm.trackit_work_order "TrackIt Work Order",
        pm.name "Project Name",
        pm.status "Project Status",
        req.last_name||', '||req.first_name||', '||req.middle_initial||'.' "Requestor Name",
        rde.department_group_descr "Requestor Department Name",
        req.department_descr "Requestor Division Name",
        
        pm.requester_ext,
        case
            when pm.requester_ext in 
                (
                select 
                    pm.requester_phone|| '(x'||pm.requester_ext ||')' "Requesters Number"
                from 
                    protrac_master pm
                where
                    pm.requester_ext is not null
                )
            
            else
                (
                select
                    pm.requester_phone "Requesters Number"
                from 
                    protrac_master pm
                )   
        end as "Requester Number",
         
        man.last_name||', '||man.first_name||', '||man.middle_initial||'.' "SME Name",
        mdg.department_group_descr "SME Department Name",
        man.department_descr "SME Division Name",
        
        pm.app_manager_ext,
        case
            when pm.app_manager_ext in 
                (
                select 
                    pm.app_manager_phone|| '(x'||pm.app_manager_ext ||')' "SME Number"
                from 
                    protrac_master pm
                where
                    pm.app_manager_phone is not null
                )
            
            else
                (
                select
                    pm.app_manager_phone "SME Number"
                from 
                    protrac_master pm
                )   
        end as "Requester Number",
    
        pm.createby_date "Date Entered",
        pm.date_begin "Date Began",
        pm.date_completed "Date Completed",
        pm.estimated_date "Estimated Completion Date"
    
    from
        protrac_master pm,
        cobr.vw_pps_payroll req, cobr.department_group rde,
        cobr.vw_pps_payroll man, cobr.department_group mdg
        
    where
        pm.requester_id         = req.emple_no and
        pm.requester_dept_id    = rde.pk_department_group_id and
        pm.app_manager_id       = man.emple_no and 
        pm.app_manager_dept_id  = mdg.pk_department_group_id
        
    order by 
        pm.pk_proj_master_id

    I think you can avoid the sub query thing simply by using the NVL2 function:

    select ...
         , NVL2( pm.requester_ext
               , pm.requester_phone|| '(x'||pm.requester_ext ||')'
               , pm.requester_phone) "Requesters Number"
           ...
         , NVL2( pm.app_manager_ext
               , pm.app_manager_phone|| '(x'||pm.app_manager_ext ||')'
               , pm.app_manager_phone) "Manager Number"
           ...
      from protrac_master pm
         , ...
    
  • Returns the selected table column header

    I don't know there is probably a way to do this.  But I have not yet found.

    I am building an application that will act as a sort of "universal" reports generator for a MySQL database tables.

    At startup, a drop-down list box is filled with the names of tables in the database.  When the user selects one of these tables, the column names are taken from the base and used to fill the column headers for the table of LabVIEW.

    The idea is that the user can select this column and enter the constraints of filter in a text box.  These constraints will then be added to the WHERE statement for this column.

    So far I've been able to find a way to return the Active cell or a selection of cells, when the user clicks on the actual data of the table.

    Is there a direct way to retrun a selected in LabVIEW column header value?

    I am dreaming that there may be some sort of workaround using transparent controls over the headers.  But because different tables will have a different number of columns that the user defines the width, I'm not really sure that it will work more.

    If you the editable headers, this allows Active cells specify that your column is - 1 column selected active line is the selected column. You may need to use the mouse down? to filter the possibility for the user to change the right column headings.

  • Possible to use a wildcard to select all columns?

    I have a large table dénormalisée with 108 columns.  I know I can "select * from ' to display all values in column, but is there a shorthand notation to select all columns except the first?

    I know that I can:

    Select * from table;

    But if I don't want col1, I do this:

    Select col2,

    col3,

    COL4,

    ...

    col107,

    col108

    table;

    Is it possible to do something like that? :

    Select (* less col1) table.


    The reason why I ask, is that I write a few features to "clone" the rows of the table.  I wrote an insert that looks like this:

    Insert into my_table (col2, col3, col4,... col107, col108)

    Select col2, col3, col4,... col107, col108

    from my_table

    where col1 = 123;

    I do not insert col1 in the table because I have a trigger and sequence that it will fill in automatically.

    Is there a shorthand notation that I could use here to avoid having to type "col2, col3, col4,... col107, col108 '?

    There is no wildcard character that will do what you ask, but this does not mean that you must manually type the 100 column names.

    Instead of doing something like this:

    SELECT column_name | ',' Of all_tab_columns WHERE table_name = 'YOUR_TABLE_NAME_HERE' AND column_id > 1 ORDER BY column_id

    Cut and paste the results in your SQL statement as required.

  • Select default columns

    From the expensive

    At the Summit, I have a report based on a table, by default all columns are plurarite. The user can select the columns to be dispalyed the Actions-> Select columns. Here I want to customize the columns default to be copied, and at the same time that the user should be able to select all the columns of shares-> Select columns.

    Dennis

    Select them columns (and other features of IR) how you want to display them by default, and then click Actions-> Save the report.

    The pop of the Save list, choose "as default report parameters"

Maybe you are looking for