SQL query to store float values in french culture.

Here is how my requirement goes..
I have an application where users can store float values into the SQL server. Here float values are period(.) based. I have now started supporting the users who use the french culture where the float values are Comma(,) based. Example: 13.75 is represented
as 13,75. Instead of making changes to my code i.e the way i am inserting/retrieving the date now, is there a way i can handle this requirement based on culture. Like, if I specify the culture, will I be able to insert float inputs as comma(,) based values
without disturbing my existing code?
Any help is appreciated
Thanks,
Chandrahas.
-Chandrahas

is there a way i can handle this requirement based on culture.
Hello Chandrahas,
SQL Server don't store any culture info for numeric values; they are plain numeric.
It's part of the frontend to represent / accept values depending on the culture setting of the client.
Olaf Helper
[ Blog] [ Xing] [ MVP]

Similar Messages

  • Write the sql query to find largest value in row wise without using   great

    write the sql query to find largest value in row wise without using
    greatest fuction?

    Another not so good way, considering you want greatest of 4 fields from a single record:
    SQL> ed
    Wrote file afiedt.buf
      1  with t as (Select 100 col1,200 col2,300 col3,400 col4 from dual
      2  union select 500,600,700,800 from dual
      3  union select 900,1000,1100,1200 from dual
      4  union select 1300,1400,1500,1600 from dual
      5  union select 1700,1800,1900,2000 from dual
      6  union select 2100,2200,2300,2400 from dual
      7  union select 2800,2700,2600,2500 from dual
      8  union select 2900,3000,3100,3200 from dual)
      9  SELECT (CASE WHEN col1 > col2 THEN col1 ELSE col2 END) Max_value
    10  FROM
    11  (SELECT (CASE WHEN col1_col2 > col2_col3 THEN col1_col2 ELSE col2_col3 END) col1,
    12         (CASE WHEN col2_col3 > col3_col4 THEN col2_col3 ELSE col3_col4 END) col2,
    13         (CASE WHEN col3_col4 > col4_col1 THEN col3_col4 ELSE col4_col1 END) col3
    14  FROM
    15  (SELECT (CASE WHEN col1 > col2 THEN col1 ELSE col2 END) col1_col2,
    16         (CASE WHEN col2 > col3 THEN col2 ELSE col3 END) col2_col3,
    17         (CASE WHEN col3 > col4 THEN col3 ELSE col4 END) col3_col4,
    18         (CASE WHEN col4 > col1 THEN col4 ELSE col1 END) col4_col1
    19* FROM t))
    SQL> /
    MAX_VALUE
           400
           800
          1200
          1600
          2000
          2400
          2800
          3200
    8 rows selected.
    SQL> Edited by: AP on Sep 21, 2010 6:29 AM

  • How to check the sql:query is return null value

    I have use :
    <sql:query var="sql1" dataSource="${db}">
    select col_name from table_name
    where a=<c:out value="${row.test1}"/>
    and b='<c:out value="${row.test2}"/>'
    </sql:query>
    So, how can I check this statement return null value which is no record within this table?

    The Result should never be null but can be empty. You can check if the Result is empty using an if tag and checking the rowCount property:
        <sql:query var="books"
          sql="select * from PUBLIC.books where id = ?" >
          <sql:param value="${bookId}" />
        </sql:query>
         <c:if test="${books.rowCount > 0}">
         </c:if>http://java.sun.com/j2ee/1.4/docs/tutorial/doc/JSTL7.html#wp84217
    Look for query Tag Result Interface

  • SQL Query to find cumulative values for a Financial Year

    Dear users,
    My requirement is to create a SQL query for a table/view where I have day-wise data. I want to find out cumulative values for financial year by giving any date. It should add the values from start of financial year till that date in the financial year.
    I think creating a view of such type will post heavy burden on resources since accuimulation will be done for each day upto that day.
    Thanks

    Dear users,
    My requirement is to create a SQL query for a
    table/view where I have day-wise data. I want to
    find out cumulative values for financial year by
    giving any date. It should add the values from start
    of financial year till that date in the financial
    year.
    I think creating a view of such type will post heavy
    burden on resources since accuimulation will be done
    for each day upto that day.
    ThanksKumar's solution will serve yours purpose but m not agreed
    I think creating a view of such type will post heavy
    burden on resources since accuimulation will be done
    for each day upto that day. Khurram

  • SQL Query constructing  for searching values in Tables single Column

    I have Table USER_SERVICES with 2 Columns USER_NAME, Services. Please find below sample data on USER_SERVICES Table.
    A user can be assigned with multiple services(service1, service2 etc.,). So we store data as below :
    USER_NAME Services
    user1 service1
    user1 service2
    user1 service3
    user2 service1
    user2 service2
    user3 service3
    user4 service4
    I need to frame a SQL Query to 'select users assigned with Service A and Service B and Service n'.
    Note: 'And' condition is used when Searching for multiple services.
    Example: The SQL Query has to dynamically handle condition if i give Single Service, multiple Services(service1 and service2 e.t.c,)
    If i say select users assigned with service1 and service2, from the above Table, result should be user1 and user2
    If i say select users assigned with service1 and service2 and service3, from the above Table, result should be user1
    If i say select users assigned with service4 from the above table, result should be user4
    If i say select users assigned with service1 from the above table, result should be user2,user1
    If i say select users assigned with service1 and service2 from the above table, result should be user2,user1
    How do i construct the SQL Query. Any help will be appreciated.
    Thanks,
    Sathish
    Alternate email: [email protected]

    How it will be stored? In a string or a table or a collection type?
    If you have it in a table you can do like this.
    with t
    as
    select 'user1' user_name, 'service1' services from dual union all
    select 'user1', 'service2' from dual union all
    select 'user1', 'service3' from dual union all
    select 'user2', 'service1' from dual union all
    select 'user2', 'service2' from dual union all
    select 'user3', 'service3' from dual union all
    select 'user4', 'service4' from dual
    t1 as
    select 'service1' services from dual union all
    select 'service2' from dual
    select distinct user_name
      from (
    select t.user_name, t.services, t1.services, count(t1.services) over(partition by t.user_name) cnt, t1.cnt cnt_1
      from t
      left join (select t1.*, count(*) over() cnt from t1) t1 on t1.services = t.services
    where cnt = cnt_1

  • SQL query returns varchar - default value type!!!

    On a field in my portal form there is a default value type of 'SQL query returns varchar', where can I put this sql to get a default value from a table?

    Hi again
    I have this code in 'additional pl/sql code' - '...before displaying the page'. But it comes up with an error when I run the form.
    declare
    prop_v varchar2(20);
    group_v varchar2(3);
    el1_v varchar2(3);
    blk varchar2(10) := 'DEFAULT';
    begin
    prop_v := p_session.get_value_as_varchar2(p_block_name=>'DEFAULT', p_attribute_name => 'l_property_p');
    group_v := p_session.get_value_as_varchar2(p_block_name=>'DEFAULT', p_attribute_name => 'l_group_p');
    select element_code
    into el1_v
    from eh_risk_element_detail
    where property_ref = prop_v
    and group_code = group_v
    and line_no = 1;
    p_session.set_value(p_block_name => blk, p_attribute_name => 'L_ELEMENT1_P', p_value => el1_v);
    end;
    Rich

  • Sql query the store that has best sell quality in pubs sample database

    In pubs database, I want to query the store in which has highest sales quality. I exec following query,
    select stores.stor_id, sum(sales.qty) as sumqty
    from stores
    join sales on stores.stor_id = sales.stor_id
    group by stores.stor_id, stores.stor_name
    Results:
    6380 Eric the Read Books 8
    7066 Barnum's 125
    7067 News & Brews 90
    7131 Doc-U-Mat: Quality Laundry and Books 130
    7896 Fricative Bookshop 60
    8042 Bookbeat 80
    The result I need is 
    7131 Doc-U-Mat: Quality Laundry and Books 130
    Could anyone give me some suggestions?
    Thanks.

    Hello,
    If you don't want to use TOP , you can try to used nested query to get MAX(SUM()) value. Please refer to the following statement:
    SELECT stores.stor_id, sum(sales.qty) as sumqty
    FROM stores
    JOIN sales ON stores.stor_id = sales.stor_id
    GROUP BY stores.stor_id, stores.stor_name
    HAVING sum(sales.qty)=
    ( SELECT max(sumqty) FROM (
    SELECT stores.stor_id, sum(sales.qty) as sumqty
    FROM stores
    JOIN sales ON stores.stor_id = sales.stor_id
    GROUP BY stores.stor_id, stores.stor_name) AS s)
    Regards,
    Fanny Liu
    Fanny Liu
    TechNet Community Support

  • LOV SQL query dependent on column value

    Hi Gurus,
    I have a tabular form, a column of which I would like to display as a dropdown whose list of values is a SQL query containing a where clause on another column value.
    For example, say the tabular form displays questions, and that the answers to the different questions are to be picked in list of values that are different for each question. I have tried the following queries for the dropdown list of values:
    1- select value_text, value_text from list_of_values_table where question_id=#QUESTION_ID#
    2- select value_text, value_text from list_of_values_table where question_id=:QUESTION_ID
    3- select value_text, value_text from list_of_values_table where question_id=&QUESTION_ID.
    In the 3 cases, I get an error when I run the application saying that the SQL statement is incorrect.
    Any ideas?
    Thanks in advance,
    Guillauem

    Anton,
    Yes, I am creating a region based on a sql query. The query is the following:
    select q.id quest_id, q.name, q.data_type_id, q.lov_flag, a.id answer_id, a.answer_text, a.org_id
    from gwb_questions q left join gwb_answers a on q.id=a.question_id, gwb_answers ans right join gwb_orgs o on ans.org_id=o.id
    where q.MODULE_ID=:P2_MODULE_ID and o.id=:P2_ORG_ID
    Now, in the 'answer_text' column, I would like to display a dropdown containing values that come from a separate table and that depend on the value of the quest_id column. So in the Column Attributes for 'answer_text', I selected Select List (query based LOV) for the Tabular Form Element, and I entered the query mentioned before in the List of Values section (select value_text, value_text from list_of_values_table lov where lov.question_id= ?).
    I am not using any API.
    Does that make sense?
    Thanks for your help,
    Guillaume

  • Need of SQL query in selecting distinct values from two tables

    hi,
    I need a query for selecting distinct values from two tables with one condition.
    for eg:
    there are two tables a & b.
    in table a there are values like age,sex,name,empno and in table b valuses are such as age,salary,DOJ,empno.
    here what i need is with the help of empno as unique field,i need to select distinct values from two tables (ie) except age.
    can anybody please help me.
    Thanks in advance,
    Ratheesh

    Not sure what you mean either, but perhaps this will start a dialog:
    SELECT DISTINCT a.empno,
                    a.name,
                    a.sex,
                    b.salary,
                    b.doj
    FROM    a,
            b
    WHERE   a.empno = b.empno;Greg

  • Sql query - Selecting last recorded values for each date in specified period

    Hello,
    Can someone please help me with my problem.
    I'm trying to get last recorded balance for each day for specific box (1 or 2) in specified period of days from ms access database using ADOTool.
    I'm trying to get that information with SQL query but so far unsuccessfully...  
    My table looks like this:
    Table name: TestTable
    Date Time Location Box Balance
    20.10.2014. 06:00:00 1 1 345
    20.10.2014. 12:00:00 1 1 7356
    20.10.2014. 18:45:00 1 1 5678
    20.10.2014. 23:54:00 1 1 9845
    20.10.2014. 06:00:02 1 2 35
    20.10.2014. 12:00:04 1 2 756
    20.10.2014. 18:45:06 1 2 578
    20.10.2014. 23:54:10 1 2 845
    21.10.2014. 06:00:00 1 1 34
    21.10.2014. 12:05:03 1 1 5789
    21.10.2014. 15:00:34 1 1 1237
    21.10.2014. 06:00:00 1 2 374
    21.10.2014. 12:05:03 1 2 54789
    21.10.2014. 15:00:34 1 2 13237
    22.10.2014. 06:00:00 1 1 8562
    22.10.2014. 10:00:00 1 1 1234
    22.10.2014. 17:03:45 1 1 3415
    22.10.2014. 22:00:00 1 1 6742
    22.10.2014. 06:00:05 1 2 562
    22.10.2014. 10:00:16 1 2 123
    22.10.2014. 17:03:50 1 2 415
    22.10.2014. 22:00:10 1 2 642
    23.10.2014. 06:00:00 1 1 9876
    23.10.2014. 09:13:00 1 1 223
    23.10.2014. 13:50:17 1 1 7768
    23.10.2014. 19:47:40 1 1 3456
    23.10.2014. 21:30:00 1 1 789
    23.10.2014. 23:57:12 1 1 25
    23.10.2014. 06:00:07 1 2 976
    23.10.2014. 09:13:45 1 2 223
    23.10.2014. 13:50:40 1 2 78
    23.10.2014. 19:47:55 1 2 346
    23.10.2014. 21:30:03 1 2 89
    23.10.2014. 23:57:18 1 2 25
    24.10.2014. 06:00:55 1 1 346
    24.10.2014. 12:30:22 1 1 8329
    24.10.2014. 23:50:19 1 1 2225
    24.10.2014. 06:01:00 1 2 3546
    24.10.2014. 12:30:26 1 2 89
    24.10.2014. 23:51:10 1 2 25
    Let's say the period is 21.10.2014. - 23.10.2014. and I want to get last recorded balance for box 1. for each day. The result should look like this:
    Date Time Location Box Balance
    21.10.2014. 15:00:34 1 1 1237
    22.10.2014. 22:00:00 1 1 6742
    23.10.2014. 23:57:12 1 1 25
    So far I've managed to write a query that gives me balance for ONLY ONE date (date with highest time in whole table), but I need balance for EVERY date in specific period.
    My incorrect code (didn't manage to implement "BETWEEN" for dates...):
    SELECT TestTable.[Date], TestTable.[Time], TestTable.[Location], TestTable.[Box], TestTable.[Balance]
    FROM TestTable
    WHERE Time=(SELECT MAX(Time)
    FROM TestTable
    WHERE Location=1 AND Box=1 );
    Tnx!
    Solved!
    Go to Solution.

    For loop
    following query keep day (here 24 in below query) Variable from ( 1 to 28-29/30/31 as per month)
    SELECT TOP 1 TestTable.[Date], TestTable.[Time], TestTable.[Location], TestTable.[Box], TestTable.[Balance]
    FROM Test Table.
    WHERE  Time=(SELECT MAX(Time) FROM TestTable WHERE Location=1 AND Box=1 )
    AND DATE = "2014-10-24";
    PBP (CLAD)
    Labview 6.1 - 2014
    KUDOS ARE WELCOMED.
    If your problem get solved then mark as solution.

  • Sql Query to store record like warehoue wise items

    Hi Experts
    I want to ask you a sql query for inserting records from two table OITM and OWHS in a user definded table like OITW.
    I have a table BINMASTER in which bin code are stored. Now I want to create a table Like OWHS where BIN Wise Item records to be stored Let See
    Item01 Bin 01
    Item02 Bin 01
    Item03 Bin 01
    Item01 Bin 02
    Item02 Bin 02
    Item03 Bin 02
    Plz give your suggestions
    Regards
    Gorge

    hi János Nagy 
    Thank for reply
    your statement is fine with no where condition. But I want to insert in a UDT in which Code, Name are two field which should be unique for every record. I use following statement
    Insert into (Code, name, Itemcode, ItemDescription, Bincode , Warehouse )
    select                                      ?,     ?, T1.Itemcode, T2.ItemDescription, T2.Bincode , T3.WhsCode From Oitm T1, T2, Owhs T3
    Here what I insert in Code and Name fields
    Regards
    Gorge

  • SQL Query - Multiple records from value of field

    I have a table that has the following lay out
    ID
    AreaUnitServes
    Filter1Quantity
    Filter1Size
    Filter2Quantity
    Filter2Size
    And I’m trying to convert it to
    FkPSAUnitsID
    Size
    Location
    I’ve got the following query started but I’m stuck on how to INSERT INTO multiple records by the value of Filter1Quantity. I also have to query for Filter2Quantity.
    INSERT
    INTO RapidServ.dbo.PSAFilters
    (FkPSAUnitsID,Size,Location)
    SELECT ID
    AS FkPSAUnitsID,Filter1Size
    AS Size,
    AreaUnitServes
    AS Location
    FROM RapidServ.dbo.PSA
    Thanks,
    why767

    Please follow basic Netiquette and post the DDL we need to answer this. Follow industry and ANSI/ISO standards in your data. You should follow ISO-11179 rules for naming data elements. You should follow ISO-8601 rules for displaying temporal data. We need
    to know the data types, keys and constraints on the table. Avoid dialect in favor of ANSI/ISO Standard SQL. And you probably need to read and download the PDF for: 
    https://www.simple-talk.com/books/sql-books/119-sql-code-smells/
    >> I have a table that has the following lay out <<
    How nice for you! Why did you draw ASCII pictures?  It has all kinds of magical names. The table is nameless because it is forbidden by a wizard to speak its name? There are generic, universal “size” and “location”of nothing in particular. Is the “fk-”
    prefix a meta data design error for “foreign key”? We never do that in RDBMS; name a data element for what it is by its nature, not for how it was used in one place in one schema. This is why we have no magical “id” in a valid schema. Data elements do not
    change names from table to table. 
    You seem to have inherited a pile of garbage with a repeated group in it. Look up First Normal Form (1NF). You also do not know why row is not a record and why fields are  not columns. Did you notice that “area_unit_serves” is a sentence and not
    a name? 
    >> I’ve got the following query started but I’m stuck on how to INSERT INTO multiple records [sic] by the value of Filter1Quantity. I also have to query for Filter2Quantity. <<
    My guess until I get a usable business rules and DDL is that you can use a UNION something like this skeleton: 
    INSERT INTO PSA_Filters (psa_units_id, filter_size, area_service_unit)
    SELECT psa_units_id, filter_1_size, area_service_unit
      FROM Magic_Nameless_Stuff
    UNION ALL
    SELECT psa_units_id, filter_2_size, area_service_unit
      FROM Magic_Nameless_Stuff;
    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
    in Sets / Trees and Hierarchies in SQL

  • SQL query concat - numeric or value error

    I am getting numeric or value error when concatenating sql script..
    Here is the sample, I have in the stored proc.. firstpart:_ works fine if I comment the secondpart:_. (I modified the query because I am posting in the public forums)
    V_SAMPLEQUERY VARCHAR2(2000);
    firstpart:_
    V_SAMPLEQUERY := '      
    SELECT
    AB.ABCDID AS ABCDID,
    CD.MEMBERID AS MEMBERID,
    CD.FNAME AS FNAME,
    CD.LNAME AS LNAME,
    CD.ACCOUNT AS ACCOUNT,
    EF.ZIP AS ZIP,
    AB.INSERTTIME AS INSERTTIME,
    AB.INSERTBY AS INSERTBY,
    ES.NAME AS STATUS,
    MYFUNCTION(E.ABCDID) AS AMOUNT,
    PA.NAME AS SOUSENAME,
    R.CODE AS BUDGETCODE,
    WX.ACCOUNTID as ACCOUNTID,
    AB.SOMETYPE AS SOMETYPE,
    AB.ACCTREP,
    ED.TYPE AS TYPE,
    AB.NOTES AS NOTES,
    GH.AREACODE || '''' || GH.PHONE_NUMBER AS PHONENUMBER,
    ED.REQUESTEDDATE,
    ED.BOOKED,
    ED.CALLERINFO
    FROM PEOPLES AB,
    LOCATIONS CD,
    LOCATIONTYPES EF,
    ACCOUNTS GH,
    ACCOUNTdetails IJ,
    ACCOUNTstatus KL,
    ACCOUNTMEMBERDETAILS MN,
    MEMBERS OP,
    BUDGET QR,
    BCODES ST,
    ACCOUNTSYSTEM UV,
    INFOCALL WX,
    PHONE_NUMBERS YZ
    WHERE AT.NAME = ''SAVINGS''
    andCD.MEMBERID = PH.MEMBERID
    andCD.MEMBERID =EF.MEMBERID
    and AT.ADDRESSTYPEID =EF.ADDRESSTYPEID
    andCD.MEMBERID =AB.MEMBERID
    andAB.STATUS = ES.STATUS(+)
    andAB.ABCDID = ED.ABCDID
    andAB.ABCDID = EP.ABCDID(+)
    and EP.MEBER_ID = PA.MEBER_ID(+)
    andAB.BID = R.BID(+)
    andAB.SAMPLEID = PR.SAMPLEID(+)
    andAB.ABCDID = BSG.ABCDID(+)
    andAB.INFOCALLID = C.INFOCALLID(+)
    and YZ.SOMETYPEID = ''10000''
    ANDAB.INSERTTIME > SYSDATE - 35
    ANDAB.INSERTTIME < ''
    AND WX.NAME IN (''ABCD'',
    ''EFGH'',
    ''IJKL'',
    ''MNOP'',
    ''QRST'',
    ''UVWX'')
    AND MN.NAME = ''FINISHED'' '
    secondpart:_ ***ERROR PART***
    V_SAMPLEQUERY := V_SAMPLEQUERY || ' ORDER BY AB.USER'; -- Here I am getting error saving ORA-06502 - numeric or value error

    Hi,
    Wheneve you have a problem, prlease post a complete test script that people can run to re-create the problem and test their ideas. Include CREATE TABLE and INSERT statements for any tables used, abnd the results you want it to produce.
    SeshuGiri wrote:
    I am getting numeric or value error when concatenating sql script.. Are you really getting the error when you concatenate, or when you try to execute the resulting string?
    Here is the sample, I have in the stored proc.. firstpart:_ works fine if I comment the secondpart:_. (I modified the query because I am posting in the public forums)
    V_SAMPLEQUERY VARCHAR2(2000);Is that big enough? It looks like the string is right around 1000 characters; depending on your character set, that could be more than 2000 bytes. VARCHAR2s in PL/SQL can hold up to 32767 bytes.
    firstpart:_
    V_SAMPLEQUERY := '      
    SELECT
    AB.ABCDID AS ABCDID,
    CD.MEMBERID AS MEMBERID,
    CD.FNAME AS FNAME,
    CD.LNAME AS LNAME,
    CD.ACCOUNT AS ACCOUNT,
    EF.ZIP AS ZIP,
    AB.INSERTTIME AS INSERTTIME,
    AB.INSERTBY AS INSERTBY,
    ES.NAME AS STATUS,
    MYFUNCTION(E.ABCDID) AS AMOUNT,
    PA.NAME AS SOUSENAME,
    R.CODE AS BUDGETCODE,
    WX.ACCOUNTID as ACCOUNTID,
    AB.SOMETYPE AS SOMETYPE,
    AB.ACCTREP,
    ED.TYPE AS TYPE,
    AB.NOTES AS NOTES,
    GH.AREACODE || '''' || GH.PHONE_NUMBER AS PHONENUMBER,
    ED.REQUESTEDDATE,
    ED.BOOKED,
    ED.CALLERINFO
    FROM PEOPLES AB,
    LOCATIONS CD,
    LOCATIONTYPES EF,
    ACCOUNTS GH,
    ACCOUNTdetails IJ,
    ACCOUNTstatus KL,
    ACCOUNTMEMBERDETAILS MN,
    MEMBERS OP,
    BUDGET QR,
    BCODES ST,
    ACCOUNTSYSTEM UV,
    INFOCALL WX,
    PHONE_NUMBERS YZ
    WHERE AT.NAME = ''SAVINGS''
    andCD.MEMBERID = PH.MEMBERID
    andCD.MEMBERID =EF.MEMBERID
    and AT.ADDRESSTYPEID =EF.ADDRESSTYPEID
    andCD.MEMBERID =AB.MEMBERIDYou need some whitespace after the keyword "and", in the line above and also several places below.
    andAB.STATUS = ES.STATUS(+)
    andAB.ABCDID = ED.ABCDID
    andAB.ABCDID = EP.ABCDID(+)
    and EP.MEBER_ID = PA.MEBER_ID(+)
    andAB.BID = R.BID(+)
    andAB.SAMPLEID = PR.SAMPLEID(+)
    andAB.ABCDID = BSG.ABCDID(+)
    andAB.INFOCALLID = C.INFOCALLID(+)
    and YZ.SOMETYPEID = ''10000''
    ANDAB.INSERTTIME > SYSDATE - 35
    ANDAB.INSERTTIME < '' Did something get cut off here?
    AND WX.NAME IN (''ABCD'',
    ''EFGH'',
    ''IJKL'',
    ''MNOP'',
    ''QRST'',
    ''UVWX'')
    AND MN.NAME = ''FINISHED'' 'It looks like you're constructing a string for EXECUTE IMMEDIATE, but why not just use a static query?
    secondpart:_ ***ERROR PART***
    V_SAMPLEQUERY := V_SAMPLEQUERY || ' ORDER BY AB.USER'; -- Here I am getting error saving ORA-06502 - numeric or value error
    USER is the name of a built-in function, which means it's not a good name for your own column. Try user_name instead.

  • Sql query to build average value

    I'm trying to build a query capture the below information. Any help is really appreciated.
    Table looks something like below.
    Room
    Subject
    Students
    A1
    Science
    10
    A1
    Maths
    20
    B1
    Science
    15
    B2
    English
    25
    C1
    Deutsch
    20
    A1
    French
    15
    C1
    English
    10
    How can i write a query so that i takes the average of students in each room and display the output? I need to write a query so that it also picks up any new rooms and students added.
    Average is sum of total students in room by number of times each room is specified.
    eg: A1 is listed 3 times a the result would be 10+20+15 divived by 3.
    A1    B1    B2    C1
    15    15    20    15
    Thanks You
    KK

    This is called pivot. And you need to know all rooms upfront. Anyway, assuming you are on 11G:
    SQL> with t as (
      2             select 'A1' room,'Science' subject,10 students from dual union all
      3             select 'A1','Maths',20 from dual union all
      4             select 'B1','Science',15 from dual union all
      5             select 'B2','English',25 from dual union all
      6             select 'C1','Deutsch',20 from dual union all
      7             select 'A1','French',15 from dual union all
      8             select 'C1','English',10 from dual
      9            )
    10  select  "'A1'_X" A1,
    11          "'B1'_X" B1,
    12          "'B2'_X" B2,
    13          "'C1'_X" C1
    14    from  t
    15    pivot(
    16          avg(students) x,
    17          max(subject) y
    18          for room in ('A1','B1','B2','C1')
    19         )
    20  /
            A1         B1         B2         C1
            15         15         25         15
    SQL>
    SY.

  • Sql Query Help to find values?

    Hi! 
    i have a table structure like this...
    you can see the image here.
    http://postimg.org/image/3k5nvkvn5/
    i which i need to find some values.
    Example: i need to find all column "District" values where value=46
    then in that case you can see in above image that row 1 to 4 has to fetched because these columns contains value between 45-52, also in row 5 where value is 46,47 the also it  has to be fetched, here i have to kind of structure to be used in table one
    is comma separated and another one is comma and dash separated value, so how can i find these values in table. so how can achieve this using query, Any help would be triplicated.

    Ah this is not correct way to store data in table
    If you store like this you've to do lots of manipulations before values can be used in  filter
    So as per above you would require something like this
    ;With Numbers(N)
    AS
    SELECT 1
    UNION ALL
    SELECT 1
    UNION ALL
    SELECT 1
    UNION ALL
    SELECT 1
    UNION ALL
    SELECT 1
    UNION ALL
    SELECT 1
    Num_Matrix(N)
    AS
    SELECT ROW_NUMBER() OVER (ORDER BY (SELECT 1))
    FROM Numbers n1
    CROSS JOIN Numbers n2
    CROSS JOIN Numbers n3
    CROSS JOIN Numbers n4
    CROSS JOIN Numbers n5
    CROSS JOIN Numbers n6
    CROSS JOIN Numbers n7
    CROSS JOIN Numbers n8
    SELECT DISTINCT t.po_city_st_zip
    FROM
    SELECT LEFT(f.Val,CHARINDEX('-',f.Val+'-')-1) AS StartVal,
    STUFF(f.Val,1,CHARINDEX('-',f.Val+'-'),'') AS EndVal,
    t.*
    FROM YourTable t
    CROSS APPLY do.ParseValues(t.District,',')f
    )m
    INNER JOIN Num_Matrix n
    ON n.N BETWEEN m.StartVal AND m.EndVal
    WHERE n.N = <your Value>
    See ParseValues UDF here                                                                 
    http://visakhm.blogspot.ae/2010/02/parsing-delimited-string.html
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

Maybe you are looking for

  • Mail App v4.2 crashes when selecting messages to be read

    I'm a bit lost as to how to diagnose this. I do not know how to log errors in the app for starters. The program starts fine, but when I select a message for viewing, it pauses for a few seconds and crashes. Has anyone else had this problem? I've re-i

  • SetBackground() useless for JComponent?

    if you extend JComponent and then use setBackground(Color.RED), actually there is no change of the background. According to the API doc, public void setBackground(Color bg) Sets the background color of this component. The background color is used onl

  • Is UWL mandatory for Workflow ?

    Hi , I am newbie to Worflow in EP. I am able to see SBWP ( SAP Mail box ) in EP and some Work flow iviews (leave req,appraisal). If i try to trigger Worflow from my leave req , i am getting the error msg " You are not one of the possible agents of th

  • Update Language for SAPSCRIPT printing

    HI, im having troubles trying to print a new invoice which is created within a new company code in a different language. I do not have any troubles printing my invoice in the initial company code/language. Are sapscript forms limited by company codes

  • Two ipad2s on the same account?

    I bought my daughter a ipad2, now we both have one. How will this work with one account?