Forcsing number formatting in Select statement
Hi. I have a select statement that truncates a number field and compares it to a parameter, but it doesn't work in InfoView or as a scheduled report in Crystal Server.
The string is :
left(totext({gl_begbal.prd-yr-no}),4) startswith totext(year({?Pm-?Period Ending Date}))
The number field is yyyymm, but Crystal Reports displays the field as 201,006, which causes the select statement to fail. When I set Options, Fields, Number to whole number, CR displays it without the comma and the statement works perfectly. However, when I bring the report into CServer or fun it in InfoView, the report fails again, and I can't find any formatting options in either Server or InfoView settings.
Is there a way to forcse the format to whole number within the select formulae?
Thanks!
Robin
Post your question to the BOE Admin forum. Likely what is happening is the BOE server has a different default date format.
Similar Messages
-
Combine two select statements in one SQL statements
I have the following two queries that I need to combine into one query, where it updates a single row at the same time.
SELECT count(*) FROM database.USAGE WHERE SERVICE_TYPE = 'C' AND ACCOUNT = "4837"
SELECT sum(minutes) FROM database.USAGE WHERE SERVICE_TYPE = 'DA' AND ACCOUNT = "4837"
I want to insert the values of each select statement into two columns of the same row, as well as insert the account number from the select statement.
After the query has been executed, the database row will look like this:
ACCOUNT COUNT SUM
4837 354 1039202
I am looking for suggestions on how to:
- either combine the two into one query
- simply update each column with the value from each query by updating the row with the account value
I am a SQL newbie - so I appreciate any assistance.
Thanks,
TonyHi, Tony,
When you're talking about changing the data in tables, "INSERT" means to add a new row, and you'll cause a lot of confusion if you use it to mean something else. So don't say
"I want to insert the values of each select statement into two columns..."; use some other word, like:
"I want to put the values of each select statement into two columns ..."
If you happened to know that those two numbers were 354 and 1039202, you might say:
UPDATE table_x
SET a_count = 354
, a_sum = 1039202
WHERE account = 4837;But you don't know the numbers; you want to have the query figure out what they are.
In most places where you can use a literal (like 354 or 1039202), you can also use a scalar sub-query, a SELECT statement, enclosed in parentheses, that produces one column and (at most) one row.
In your case, you can say:
UPDATE table_x
SET a_count = (SELECT count(*) FROM database.USAGE WHERE SERVICE_TYPE = 'C' AND ACCOUNT = 4837)
, a_sum = (SELECT sum(minutes) FROM database.USAGE WHERE SERVICE_TYPE = 'DA' AND ACCOUNT = 4837
WHERE account = 4837;or, to make it more readable:
UPDATE table_x
SET a_count =
( SELECT count (*)
FROM database.USAGE
WHERE SERVICE_TYPE = 'C'
AND ACCOUNT = 4837
, a_sum =
( SELECT sum (minutes)
FROM database.USAGE
WHERE SERVICE_TYPE = 'DA'
AND ACCOUNT = 4837
WHERE account = 4837;By the way, why are you using double-quotes around 4837? If it's a string, enclose it in single quotes. If it's a number (which I'm assuming in my code), don't enclose it in anything.
WARNING: scalar sub-queries are somewhat like duct tape: they're extremely useful in certain places, and those places account for about 1% of their use. The other 99% of the time, there's a better way to do things, though the better way may require more expertise. -
Create object type from multiple tables for select statement
Hi there,
I have 3 tables as given below and I wish to create an object type to group selected columns as 'attribute' from multiple tables.
I need to create 2 input parameters to pass in - 'attribute' and 'attribute value' in PL/SQL and these 2 parameters will be
passing in with 'column name' and 'column value'. e.g. 'configuration' - the column name, 'eval' - the column value.
Then, the PL/SQL will execute the select statement with the column and column value provided to output the record.
Pls advise and thank you.
table ccitemnumber
name null type
ccitemnumber not null varchar2(20)
configuration varchar2(20)
item_type varchar2(30)
table productmodel
productmodelnumber not null varchar2(6)
description varchar2(60)
accesstimems number
numberofheads varchar2(2)
generation varchar2(10)
numberofdiscs varchar2(2)
factoryapplication varchar2(150)
table topmodel
stmodelnumber not null varchar2(30)
productfamily varchar2(60
formfactor varchar2(10)
modelheight varchar2(10)
formattedcapacity number
formattedcapacity_uom varchar2(20)
object type in database
configuration varchar2(20)
item_type varchar2(30)
numberofheads varchar2(2)
generation varchar2(10)
numberofdiscs varchar2(2)
factoryapplication varchar2(150)
modelheight varchar2(10)
formattedcapacity number
formattedcapacuser12043838 wrote:
Reason to do this as these fields are required to be grouped together as they are created in different tables. They are treated as 'attribute' (consists of many columns) of the part number. So, the PL/SQL is requested to design in a way able for user to pass in the column name and column value or part number, then the select statement should be able to query for the records. Another reason is a new column can be added easily without keep modifying those effected programs. Reuseable too.This basically equates to ... hard to code, hard to maintain, and poor performance.
Are you really sure you want to do this? This isn't going to be easy-street as you seem to think it is, but it's a one way street to a poorly performing system with security vulnerabilities (google SQL Injection).
I would highly recommend you reconsider your design decision here. -
I want a select statement to return two values, sum of one column and customer number
I have two columns one called invoice_number and the other invoice_amount. I want a select statement to return two columns.... invoice_number and then the sum of the invoice_amount(s) for each unique invoice number.
SELECT sum(invoice_amount) AS Totalinvoice_amount FROM InvoiceTB where invoice_number = 'INV102'
This is where I've started, which returns:
Totalinvoice_amount
500.00
Any help is appreciated.
Please mark my post as helpful or the answer or better yet.... both! :) Thanks!Please post DDL, so that people do not have to guess what the keys, constraints, Declarative Referential Integrity, data types, etc. in your schema are. Learn how to follow ISO-11179 data element naming conventions and formatting rules. Temporal data should
use ISO-8601 formats. Code should be in Standard SQL as much as possible and not local dialect.
This is minimal polite behavior on SQL forums.
--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 -
How to find the number of fetched lines from select statement
Hi Experts,
Can you tell me how to find the number of fetched lines from select statements..
and one more thing is can you tell me how to check the written select statement or written statement is correct or not????
Thanks in advance
santoshHi,
Look for the system field SY_TABIX. That will contain the number of records which have been put into an internal table through a select statement.
For ex:
data: itab type mara occurs 0 with header line.
Select * from mara into table itab.
Write: Sy-tabix.
This will give you the number of entries that has been selected.
I am not sure what you mean by the second question. If you can let me know what you need then we might have a solution.
Hope this helps,
Sudhi
Message was edited by:
Sudhindra Chandrashekar -
How can I limit the number of rows returned by a select stat
How can I limit the number of rows returned by a select
statement. I have a query where I return the number of stores
that are located in a given area.. I only want to return the
first twenty-five stores. In some instances there may be over
200 stores in a given location.
I know is SQL 7 that I can set the pagesize to be 25....
Anything similiar in Oracle 8i?
nullDebbie (guest) wrote:
: Chad Nale (guest) wrote:
: : How can I limit the number of rows returned by a select
: : statement. I have a query where I return the number of
: stores
: : that are located in a given area.. I only want to return the
: : first twenty-five stores. In some instances there may be
: over
: : 200 stores in a given location.
: : I know is SQL 7 that I can set the pagesize to be 25....
: : Anything similiar in Oracle 8i?
: If you are in Sql*Plus, you could add the statement
: WHERE rownum <= 25
: Used together with an appropriate ORDER BY you
: could get the first 25 stores.
Watch out. ROWNUM is run before ORDER BY so this would only
order the 25 selected
null -
Number of records in cursor select statement
hi all,
with the cursor i am selecting set of select statement and writing into the .txt file.
its working file, but it should not open the file if the cursor returns nothing.
how to check for the number of records return by the select statement in the cursor.
pls help me.
Thanks..Hi,
You can use a Cursor for loop (you'll not enter in the loop if the SELECT is retrieving no rows):
begin
for recs in(select * from whatever) loop
null; -- Produce your file
end loop;
end;You can also use a bulk collect and check "yourcollection.count" attribute ... (but don't use it if you are processing a lot of records!) -
Using column number inplace of column name in SQL Select statement
Is there a way to run sql select statements with column numbers in
place of column names?
Current SQL
select AddressId,Name,City from AddressIs this possible
select 1,2,5 from AddressThanks in Advanceuser10962462 wrote:
well, ok, it's not possible with SQL, but how about PL/SQL?As mentioned, using DBMS_SQL you can only really use positional notation... and you can also use those positions to get the other information such as what the column is called, what it's datatype is etc.
CREATE OR REPLACE PROCEDURE run_query(p_sql IN VARCHAR2) IS
v_v_val VARCHAR2(4000);
v_n_val NUMBER;
v_d_val DATE;
v_ret NUMBER;
c NUMBER;
d NUMBER;
col_cnt INTEGER;
f BOOLEAN;
rec_tab DBMS_SQL.DESC_TAB;
col_num NUMBER;
v_rowcount NUMBER := 0;
BEGIN
-- create a cursor
c := DBMS_SQL.OPEN_CURSOR;
-- parse the SQL statement into the cursor
DBMS_SQL.PARSE(c, p_sql, DBMS_SQL.NATIVE);
-- execute the cursor
d := DBMS_SQL.EXECUTE(c);
-- Describe the columns returned by the SQL statement
DBMS_SQL.DESCRIBE_COLUMNS(c, col_cnt, rec_tab);
-- Bind local return variables to the various columns based on their types
FOR j in 1..col_cnt
LOOP
CASE rec_tab(j).col_type
WHEN 1 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,2000); -- Varchar2
WHEN 2 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_n_val); -- Number
WHEN 12 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_d_val); -- Date
ELSE
DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,2000); -- Any other type return as varchar2
END CASE;
END LOOP;
-- Display what columns are being returned...
DBMS_OUTPUT.PUT_LINE('-- Columns --');
FOR j in 1..col_cnt
LOOP
DBMS_OUTPUT.PUT_LINE(rec_tab(j).col_name||' - '||case rec_tab(j).col_type when 1 then 'VARCHAR2'
when 2 then 'NUMBER'
when 12 then 'DATE'
else 'Other' end);
END LOOP;
DBMS_OUTPUT.PUT_LINE('-------------');
-- This part outputs the DATA
LOOP
-- Fetch a row of data through the cursor
v_ret := DBMS_SQL.FETCH_ROWS(c);
-- Exit when no more rows
EXIT WHEN v_ret = 0;
v_rowcount := v_rowcount + 1;
DBMS_OUTPUT.PUT_LINE('Row: '||v_rowcount);
DBMS_OUTPUT.PUT_LINE('--------------');
-- Fetch the value of each column from the row
FOR j in 1..col_cnt
LOOP
-- Fetch each column into the correct data type based on the description of the column
CASE rec_tab(j).col_type
WHEN 1 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_v_val);
DBMS_OUTPUT.PUT_LINE(rec_tab(j).col_name||' : '||v_v_val);
WHEN 2 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_n_val);
DBMS_OUTPUT.PUT_LINE(rec_tab(j).col_name||' : '||v_n_val);
WHEN 12 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_d_val);
DBMS_OUTPUT.PUT_LINE(rec_tab(j).col_name||' : '||to_char(v_d_val,'DD/MM/YYYY HH24:MI:SS'));
ELSE
DBMS_SQL.COLUMN_VALUE(c,j,v_v_val);
DBMS_OUTPUT.PUT_LINE(rec_tab(j).col_name||' : '||v_v_val);
END CASE;
END LOOP;
DBMS_OUTPUT.PUT_LINE('--------------');
END LOOP;
-- Close the cursor now we have finished with it
DBMS_SQL.CLOSE_CURSOR(c);
END;
SQL> exec run_query('select empno, ename, deptno, sal from emp where deptno = 10');
-- Columns --
EMPNO - NUMBER
ENAME - VARCHAR2
DEPTNO - NUMBER
SAL - NUMBER
Row: 1
EMPNO : 7782
ENAME : CLARK
DEPTNO : 10
SAL : 2450
Row: 2
EMPNO : 7839
ENAME : KING
DEPTNO : 10
SAL : 5000
Row: 3
EMPNO : 7934
ENAME : MILLER
DEPTNO : 10
SAL : 1300
PL/SQL procedure successfully completed.
SQL> exec run_query('select * from emp where deptno = 10');
-- Columns --
EMPNO - NUMBER
ENAME - VARCHAR2
JOB - VARCHAR2
MGR - NUMBER
HIREDATE - DATE
SAL - NUMBER
COMM - NUMBER
DEPTNO - NUMBER
Row: 1
EMPNO : 7782
ENAME : CLARK
JOB : MANAGER
MGR : 7839
HIREDATE : 09/06/1981 00:00:00
SAL : 2450
COMM :
DEPTNO : 10
Row: 2
EMPNO : 7839
ENAME : KING
JOB : PRESIDENT
MGR :
HIREDATE : 17/11/1981 00:00:00
SAL : 5000
COMM :
DEPTNO : 10
Row: 3
EMPNO : 7934
ENAME : MILLER
JOB : CLERK
MGR : 7782
HIREDATE : 23/01/1982 00:00:00
SAL : 1300
COMM :
DEPTNO : 10
PL/SQL procedure successfully completed.
SQL> exec run_query('select * from dept where deptno = 10');
-- Columns --
DEPTNO - NUMBER
DNAME - VARCHAR2
LOC - VARCHAR2
Row: 1
DEPTNO : 10
DNAME : ACCOUNTING
LOC : NEW YORK
PL/SQL procedure successfully completed.
SQL> -
Number of rows inserted is different in bulk insert using select statement
I am facing a problem in bulk insert using SELECT statement.
My sql statement is like below.
strQuery :='INSERT INTO TAB3
(SELECT t1.c1,t2.c2
FROM TAB1 t1, TAB2 t2
WHERE t1.c1 = t2.c1
AND t1.c3 between 10 and 15 AND)' ....... some other conditions.
EXECUTE IMMEDIATE strQuery ;
These SQL statements are inside a procedure. And this procedure is called from C#.
The number of rows returned by the "SELECT" query is 70.
On the very first time call of this procedure, the number rows inserted using strQuery is *70*.
But in the next time call (in the same transaction) of the procedure, the number rows inserted is only *50*.
And further if we are repeating calling this procedure, it will insert sometimes 70 or 50 etc. It is showing some inconsistency.
On my initial analysis it is found that, the default optimizer is "ALL_ROWS". When i changed the optimizer mode to "rule", this issue is not coming.
Anybody faced these kind of issues?
Can anyone tell what would be the reason of this issue..? any other work around for this...?
I am using Oracle 10g R2 version.
Edited by: user13339527 on Jun 29, 2010 3:55 AM
Edited by: user13339527 on Jun 29, 2010 3:56 AMYou have very likely concurrent transactions on the database:
>
By default, Oracle Database permits concurrently running transactions to modify, add, or delete rows in the same table, and in the same data block. Changes made by one transaction are not seen by another concurrent transaction until the transaction that made the changes commits.
>
If you want to make sure that the same query always retrieves the same rows in a given transaction you need to use transaction isolation level serializable instead of read committed which is the default in Oracle.
Please read http://download.oracle.com/docs/cd/E11882_01/appdev.112/e10471/adfns_sqlproc.htm#ADFNS00204.
You can try to run your test with:
set transaction isolation level serializable;If the problem is not solved, you need to search possible Oracle bugs on My Oracle Support with keywords
like:
wrong results 10.2Edited by: P. Forstmann on 29 juin 2010 13:46 -
How display number of row in select statement
How can I display number of row in select statement?
Table
data1 data2
xxx ccd
wss qwe
qws uij
I need get from SELECT statement:
1 xxx ccd
2 wss qwe
3 qws uijuser13734495 wrote:
Thank you from answer.
Statement
select rownum rn, data1, data2 from table
is good.
And what have I do went I use
select rownum rn, data1, data2 from table order by data1
and I get
3 qws uij
2 wss qwe
1 xxx ccd
I need
1 qws uij
2 wss qwe
3 xxx ccdhence the importance of describing the complete problem.
select
rownum,
data1,
data2
from(
select
data1,
data2
from
table
order by
data1) -
How to display number of rows as columns in a select statement? This is on
How to display number of rows as columns in a select statement? This is on 10g R2.
Thanks,
RFor the current (ie. row 1 of 100)
row_number over (order by -pick_a_column_set) as rnfor the total number of columns returned in your query
count(*) over() as total_count -
Gettingant to row number in select statement
Hello,
I want to retrieve the row number of a record in the select statement. Can anybody help me in writing a query for this in php.
Thanks
Omkarsoft<a> developerLookup ROWNUM.
Followup questions belong in a SQL forum, not the PHP forum :) -
Count the number of rows resulting from a select statement
Hi,
Is there any way of counting the number of rows resulting from a select statement. i.e I have a select distinct statement and I then want to perform an IF statement on the number of rows resulting from the select statement.
Any help appreciated
Thanks
GaryDeclare
var1 number;
Begin
select count(distinct column_name) into
var1 from table_name;
If var1 > x Then
End IF;
End;
Hope I understood the problem correctly
null -
One select Statement - Number of hits displaying in ST05
Hi,
I am using single select statement on MARA table along with that using SELECT FOR ALL Entries,
However, I am getting number of hits for each records in ST05 like 2,3,8,2,2 etc.
I need to reduce number of hits by using single query only... please suggest..
Thanks,
SaiHi Siegfried,
just out of curiosity:
> You can get identicals on FAE for at least 3 reasons:
> + duplicates in the driver table, remove as written above
> + duplicate execution of the SELECT
> + fieldlist smaller than the primary key, which is not the case here
What exactly do you mean with the last point?
fieldlist in the select statement like this?
data it like table of t100.
select sprsl arbgb msgnr
from t100 into table it up to 500 rows.
select "sprsl" from t100 into table it
FOR ALL ENTRIES IN it
where sprsl = it-sprsl
and arbgb = it-arbgb
and msgnr = it-msgnr.
or field list in the where clause like this?
data it like table of t100.
select sprsl arbgb msgnr
from t100 into table it up to 50000 rows.
DELETE ADJACENT DUPLICATES FROM it COMPARING sprsl arbgb.
select sprsl from t100 into table it
FOR ALL ENTRIES IN it
where "sprsl" = it-sprsl
and "arbgb" = it-arbgb.
Or something else?
I'm asking because i've never heard or seen this before as a problem reg. identicals
for FAE. Only duplicates in driver tables or multiple executions of the FAE with the same
driver table contents (or parts of it).
If we have a smaller select field list we may read too many records which are thrown away in thd database interface
because of the distinct property of the FAE (distinct sprsl in the 2nd case) but we don't see identical selects in ST05.
How does a FAE that produces identical selects with unique driver table that is executed once look like?
So I'm a little bit confused what you meant here... .
Kind regards,
Hermann -
How do I change the number formatting within a Cell Table in Microsoft Word?
Hi, I was wondering if someone could help me out on an issue I've been having... I work for an accounting firm and we do a lot of financial statements.
I was wondering if we would be able to treat a cell table in Microsoft Word 2007 like I would a cell table in Microsoft Excel. Meaning, I would like to change the formatting of the numbers in the table to the "Accounting" (number) format so it
aligns by the decimal point and use the $ signs and () for negative numbers. We do use the link tables feature, however, most of our balancing pages just can't be done in Excel because of the way the text is written. It would be much harder to format
the text if it were to be typed in Excel. We have also tried creating an Excel sheet within Microsoft Word but it is the same as linking the tables... Again, a text formatting issue. The only option is to use tables within Word but how do we change
the number formatting to a "accounting" (number) format where the numbers would align with the decimal point and use () for the negative numbers. Is there ANY option for us to do this other than manually entering this information in using tabs?
If there are no options other than entering it in manually, please consider this as an option for your next software update. I believe that a LOT of people out there will be interested in this feature... My manager and I just attended a webinar on Microsoft
Advanced Word Tips Tricks and Techniques and 75% of the attending people had this question but no answer.
Thank you very much for your help!!!!!Word does not really have number formatting for table cells. You can align cell contents on the decimal point, though, by setting a so-called decimal tab stop.
Option 1:
- Select the cells for which you want to do this.
- Display the ruler.
- Click the Tab box on the left hand side of the ruler until the box contains an inverted T with a dot.
- Click in the ruler where you want the decimal tab.
Option 2:
- Select the cells for which you want to do this.
- Click the arrow in the lower right corner of the Paragraph group on the Home tab of the ribbon.
- Click the Tabs... button in the lower left corner of the dialog.
- Specify a tab position in the box, e.g. 1.5".
- Select the 'Decimal' radio button under 'Alignment'.
- Click Set.
- Click OK.
You will have to type the numbers as they should appear, including the $ for currency and the ( ) for negative numbers.
Regards, Hans Vogelaar
Maybe you are looking for
-
Can two people access WWF from an iPad, one way or the other?
I have downloaded Words with Friends on my iPad3, and I can play it via the WWF app icon, but if I try to access WWF via my Facebook page on the iPad, nothing happens. The same is true for my wife; she cannot access WWF via her Facebook page on the
-
Have a B/W G3 with an OEM hard drive (IBM Model DTTA-351290 E182115 HG) running System 9. Could not get OS 10.3 to install properly (always froze a quarter of the way through installation). Removed the hard drive and put in in a G4. Then installed 10
-
I cannot even step up my ePrint - it won't send me my "forgotten" password, it give me this error. The screen offers NO help and no contact info for this feature of the printer.
-
Return material to warehouse - used materials
Dear All, We have a scenerio that materials are issued by the Warehouse and it will be returned too. But somecases used materials are returned and of lesser value when compared to the new materials. but we need to keep a track of the used materials a
-
I would like to add a 2-3 minute segment of a longer movie to my web site. I use wordpress which only allows for a 2MB media clip to be uploaded. What compression in Compressor (or elsewhere) would give me such a small file? Or is there another ro