Sum of values in same column of all tables
On the same sheet, I have multiple tables with the same column (F) titled "AMOUNT".
I want to get the sum of all the values in that column, from every table, without having to specify each table.
Is there a way to do this?
It would be nice to not have to specify each table but it can't be done that way. Nonetheless, it is easy to get those sums. Type in =SUM( then click on the column letter (F in this case) of each of those tables until you have them all then add the closing parenthesis and hit return.
Similar Messages
-
How to display integer values and decimal values in same column in a table
hi
in my report amount column is there in that column integer values (2234) and decimal values (3562.34)
i want to print this values as 1000 separate as like 2,234 as integer and 3,562.34 as decimal
but this values print like 2,234.00 as integer and 3,562.34 as decimalHi akilreddy,
Per my understanding you have an field which data type may be "float" in the DB, so it have value which format like "2234" and "3562.34" in the same column, now you want to format them differently in the report, right?
I have tested on my local environement and you can use the expression in the custom format in the Textbox properties to do this:
Right click the field which you want to add the format and select the "Text Box Properties"
Select the "Number" on the left pane and using expression below in the Custom format:
=IIF(Split(Fields!yourfieldname.Value,".").Length=2,"#,###.##",Nothing)
Or you can just use "#,###.##" in the format.
Preview you will go the result like below:
If you still have any problem, please feel free to ask.
Regards
Vicky Liu
Vicky Liu
TechNet Community Support -
Count number of distinct values for a column for all tables that contains that column
Imagine I have one Column called cdperson. With the query below I know which Tables have column cdperson
select
t.[name]fromsys.schemassinnerjoin
sys.tables
tons.schema_id=t.schema_idinnerjoin
sys.columnscont.object_id=c.object_idinnerjoin
sys.types
donc.user_type_id=d.user_type_idwherec.name ='cdperson'
now I want to know for each table, how many distinct values of cdperson I have and I want the result ordered by the table that has more distinct values (descending)
Table1
cdperson select distinct(cdperson) = 10
cdadress
quant
Table2 with
cdaddress (no column cdperson in this table)
quant
Table3
cdperson select distinct(cdperson) = 100
value
Table 4
cdperson select distinct(cdperson) = 18
sum
I want this result ordered by number of distinct cdperson
table3 100
table4 18
table 10
Thks for your answersI had to add schema name to the above script to make it work in AdventureWorks:
CREATE TABLE #temp(TableName sysname , CNT BIGINT)
DECLARE @QRY NVARCHAR(MAX);
SET @qry=(SELECT
N'INSERT INTO #TEMP SELECT '''+schema_name(t.schema_id)+'.'+T.[name] +''' AS TableName, COUNT (DISTINCT ProductID) DistCount FROM '+
schema_name(t.schema_id)+'.'+t.[name] +';'
FROM sys.schemas s INNER JOIN sys.tables t ON s.schema_id=t.SCHEMA_ID
INNER JOIN sys.columns c ON t.object_id=c.object_id INNER JOIN sys.types d ON c.user_type_id=d.user_type_id
WHERE c.name ='ProductID'
FOR XML PATH(''))
EXEC(@QRY)
SELECT * FROM #temp ORDER BY TableName
DROP TABLE #temp
Production.Product 504
Production.ProductCostHistory 293
Production.ProductDocument 31
Production.ProductInventory 432
Production.ProductListPriceHistory 293
Production.ProductProductPhoto 504
Production.ProductReview 3
Production.TransactionHistory 441
Production.TransactionHistoryArchive 497
Production.WorkOrder 238
Production.WorkOrderRouting 149
Purchasing.ProductVendor 211
Purchasing.PurchaseOrderDetail 211
Sales.SalesOrderDetail 266
Sales.ShoppingCartItem 3
Sales.SpecialOfferProduct 295
Kalman Toth Database & OLAP Architect
SQL Server 2014 Database Design
New Book / Kindle: Beginner Database Design & SQL Programming Using Microsoft SQL Server 2014 -
How to calculate the sum of the values of some columns of a table
hi
i want to get in the column averages just the average of the values of some columns not all the columns of the table.what i have to change exactly in this block diagram.even if the size of the table is 25,i want the division to be the number of values in each column(= number of rows)
just like that:
Solved!
Go to Solution.
Attachments:
operations on some columns.vi 10 KBi did exactely what u told me, i think i missed something because i don't get the average value of the rows i want
Attachments:
average.vi 11 KB -
How to search all columns of all tables in a database
i need to search all columns of all tables in a database , i already write the code below , but i've got the error message below when run this script
DECLARE
cnt number;
v_data VARCHAR2(20);
BEGIN
v_data :='5C4CA98EAC4C';
FOR t1 IN (SELECT table_name, column_name FROM all_tab_cols where owner='admin' and DATA_TYPE='VARCHAR2') LOOP
EXECUTE IMMEDIATE 'SELECT COUNT(*) FROM ' ||t1.table_name|| ' WHERE ' ||t1.column_name || ' = :1' INTO cnt USING v_data;
IF cnt > 0 THEN
dbms_output.put_line( t1.table_name ||' '||t1.column_name||' '||cnt );
END IF;
END LOOP;
END;
Error report:
ORA-00933: SQL command not properly ended
ORA-06512: at line 7
00933. 00000 - "SQL command not properly ended"
*Cause:
*Action:
Any help pleaseSQL solutions by Michaels
michaels> var val varchar2(5)
michaels> exec :val := 'as'
PL/SQL procedure successfully completed.
michaels> select distinct substr (:val, 1, 11) "Searchword",
substr (table_name, 1, 14) "Table",
substr (t.column_value.getstringval (), 1, 50) "Column/Value"
from cols,
table
(xmlsequence
(dbms_xmlgen.getxmltype ('select ' || column_name
|| ' from ' || table_name
|| ' where upper('
|| column_name
|| ') like upper(''%' || :val
|| '%'')'
).extract ('ROWSET/ROW/*')
) t
-- where table_name in ('EMPLOYEES', 'JOB_HISTORY', 'DEPARTMENTS')
order by "Table"or
11g upwards
SQL> select table_name,
column_name,
:search_string search_string,
result
from (select column_name,
table_name,
'ora:view("' || table_name || '")/ROW/' || column_name || '[ora:contains(text(),"%' || :search_string || '%") > 0]' str
from cols
where table_name in ('EMP', 'DEPT')),
xmltable (str columns result varchar2(10) path '.')
TABLE_NAME COLUMN_NAME SEARCH_STRING RESULT
DEPT DNAME es RESEARCH
EMP ENAME es JAMES
EMP JOB es SALESMAN
EMP JOB es SALESMAN
4 rows selected. -
Need to compare values in two columns of one table against values in two columns in another table
Hi, as the title reads, I'm looking for an approach that will allow me to compare values in two columns of one table against values in two columns in another table.
Say, for instance, here are my tables:
Table1:
Server,Login
ABCDEF,JOHN
ABCDEF,JANE
FEDCBA,SEAN
FEDCBA,SHAWN
Table2:
Server,Login
ABCDEF,JOHN
ABCDEF,JANE
FEDCBA,SHAWN
In comparing the two tables, I'd like my query to report the rows in table1 NOT found in table2. In this case, it'll be the 3rd row of table one:
Server,Login
FEDCBA,SEAN
Thanks.create table Table1([Server] varchar(50), Login varchar(50))
Insert into Table1 values ('ABCDEF','JOHN'),('ABCDEF','JANE'),('FEDCBA','SEAN'),('FEDCBA','SHAWN')
create table Table2([Server] varchar(50), Login varchar(50))
Insert into Table2 values ('ABCDEF','JOHN'),('ABCDEF','JANE'), ('FEDCBA','SHAWN')
select [Server] ,Login from Table1
Except
select [Server] ,Login from Table2
select [Server] ,Login from Table1 t1
where not exists(Select 1 from Table2 where t1.[Server] = t1.[Server] AND Login=t1.Login)
drop table Table1,Table2 -
Multiple values from same column in diffetent columns in same row??
Hi all,
I am wondering how you can display different values from the same column into different columns on same row. For example using a CASE statement I can:
CASE WHEN CODE IN ('1', '3') THEN COUNT( ID) END as "Y"
CASE WHEN CODE NOT IN ('1', 'M') THEN COUNT( ID) END as "N"
Yes this will produce two columns needed but will also produce two separate records and null values for the empty's.
Any ideas?
ThanksIt's not clear what you want.
Can you post some examples as described in the FAQ: {message:id=9360002}
As my first guess, I would think you're looking for something like...
SQL> select * from emp;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7369 SMITH CLERK 7902 17-DEC-1980 00:00:00 800 20
7499 ALLEN SALESMAN 7698 20-FEB-1981 00:00:00 1600 300 30
7521 WARD SALESMAN 7698 22-FEB-1981 00:00:00 1250 500 30
7566 JONES MANAGER 7839 02-APR-1981 00:00:00 2975 20
7654 MARTIN SALESMAN 7698 28-SEP-1981 00:00:00 1250 1400 30
7698 BLAKE MANAGER 7839 01-MAY-1981 00:00:00 2850 30
7782 CLARK MANAGER 7839 09-JUN-1981 00:00:00 2450 10
7788 SCOTT ANALYST 7566 19-APR-1987 00:00:00 3000 20
7839 KING PRESIDENT 17-NOV-1981 00:00:00 5000 10
7844 TURNER SALESMAN 7698 08-SEP-1981 00:00:00 1500 0 30
7876 ADAMS CLERK 7788 23-MAY-1987 00:00:00 1100 20
7900 JAMES CLERK 7698 03-DEC-1981 00:00:00 950 30
7902 FORD ANALYST 7566 03-DEC-1981 00:00:00 3000 20
7934 MILLER CLERK 7782 23-JAN-1982 00:00:00 1300 10
14 rows selected.
SQL> select count(case when deptno in (10,20) then deptno end) as deptno_10_20
2 ,count(case when deptno > 20 then deptno end) as deptno_30plus
3 from emp;
DEPTNO_10_20 DEPTNO_30PLUS
8 6 -
Dear All,
I want to configure a FMS at a title level UDF. I wolud like to save the sum value of a column values in that title field.
For example,
A B
1 10000
2 10000
3 10000
4 10000
40000
I want to reflect the 40000 value in a title level UDF through FMS.
How can I write a query for this requirement??
Thanks in advance...
Regards,
Suresh YerraDear István K#rös,
Thanks. I have posted this question, is there any way to get the solution without doing coding. To solve this we need to use SDK.
Thank you once again for your quick response.
Thanks,
Suresh Yerra -
TableView - Filter more than one value in same column
Hi folks,
I faced a problem on <b>filtering a field more than one value</b>.
Does it possible solution for us to bring out filtering function while user try to enter few values in the SAME filter field?
Thank you.
First, i need to clarify my exact problem.
--> I have created one tableView with filter = "server". Then i want to allow my user to enter few filter values in same field column.
Example 1:
Before
COL1 COL2 COL3 COL4
l--II--
l-filter1I--I--
*filter1 = AAA, BBB
AAA AAA AAA AAA
BBB BBB BBB BBB
CCC CCC CCC CCC
DDD DDD DDD DDD
EEE EEE EEE EEE
After
COL1 COL2 COL3 COL4
l--II--
l-filter1I--I--
*filter1 = AAA, BBB
AAA AAA AAA AAA
BBB BBB BBB BBB
Is that any good suggestions to solve my doubt?
Message was edited by:
GP Pohcheck out this work around. in this sample currency column supports multiple values and multiple values in the filter column should be enter with comma as separater.
<u><b>page attribute:</b></u>
filtertab TYPE RSELOPTION
filter_wa TYPE RSDSSELOPT
itab TYPE FLIGHTTAB
<u><b>layout</b></u>
<%@page language="abap" %>
<%@extension name="htmlb" prefix="htmlb" %>
<htmlb:content design="design2003" >
<htmlb:page title=" " >
<htmlb:form>
<htmlb:textView id ="tex"
text = "Filter on Currency Column support multiple values, they can be entered with comma as separater like 'usd,DEM'"/>
<htmlb:tableView id = "tv1"
design = "ALTERNATING"
table = "<%= itab %>"
filter = "APPLICATION"
columnHeaderVisible = "true"
sort = "SERVER" />
</htmlb:form>
</htmlb:page>
</htmlb:content>
<u><b>oninitialization</b></u>
select * from sflight into table itab where currency in filtertab .
<u><b>oninputprocessing</b></u>
* event handler for checking and processing user input and
* for defining navigation
DATA: table TYPE REF TO cl_htmlb_tableview .
DATA: tv_data TYPE REF TO cl_htmlb_event_tableview.
DATA: filter_value TYPE string .
DATA: fil_val TYPE STANDARD TABLE OF string ,
fil_val_wa TYPE string .
REFRESH filtertab .
table ?= cl_htmlb_manager=>get_data( request = request
name = 'tableView'
id = 'tv1' ).
IF table IS NOT INITIAL .
tv_data = table->data .
IF NOT tv_data IS INITIAL .
CALL METHOD tv_data->get_row_filter_value
EXPORTING
column_index = 6
RECEIVING
value = filter_value.
IF NOT filter_value IS INITIAL .
TRANSLATE filter_value TO UPPER CASE .
REFRESH fil_val .
SPLIT filter_value AT ',' INTO TABLE fil_val .
CLEAR fil_val_wa .
LOOP AT fil_val INTO fil_val_wa .
filter_wa-sign = 'I' .
filter_wa-option = 'EQ' .
filter_wa-low = fil_val_wa .
APPEND filter_wa TO filtertab .
ENDLOOP .
ELSE .
REFRESH filtertab .
ENDIF .
ENDIF .
ENDIF .
Regards
Raja -
Sum of values in a column in alv
i am displaying data in a hierarchical list using OO programming.
I have created a hot spot for a particular field so that i display a
popup on clicking any value in that column.
The popup displays another alv grid.
I need to sum up the values of a particular column in that a;v grid
that is displayed in the popup using OO prog.
Could anyone suggest a mthod that helps summing the column values/Hello Rohan,
Hope you are ready with the event handler method and other supporting stuff. Only thing missing is before calling second screen you need to set DO_SUM field in field catalog table and pass that field catalog for the second alv.
Refer to SAP help [http://help.sap.com/saphelp_47x200/helpdata/en/52/5f0607e02d11d2b47d006094192fe3/frameset.htm] for more details.
Thanks,
Augustin. -
How to search all columns of all tables in a database for a keyword?
Dear Team,
i have an requirement that : i want to search all the columns of all the tables in the particular database based on the specific key word or an free text.
example :
table 1: columns data
empname sam
empid 01
table 2 columns data
deptname sam
departmentid 10
table 3 columns data
organization name sam
organization id 1
when i search for text " SAM"
it should search me from the entire database, all tables and columns of it and display the result
output : tablename cloumn value
table1 empname sam
table2 deptname sam
table3 organizationame sam
the example is just an sample not the real data .
please help me with sample code or any link related to it .
thanks in advanceHi justin , thanx for the reply
the basic requirement that we required is ,
the user will just type the keyword( value in the coumn) he required and it should search all the tables and columns of the table in the database and i have to show this in the front ent in the table format. here the user will analyse the information based on the search .
it is just like the google search we does( type the keyword in free text) it will display the result.
so for that i have to search entire table and columns in the whole database.
please if any one provides me the solution it will be help full for me.
thanx in advance -
Hi All,
Am using OPENROWSET to load the file data into table, here the problem is i need to map same input value to two different columns of table, As format file doesn't allow the duplicate numbers am unable to insert same value to two columns, please help me to
find a solution for this.
i can use only OPENROWSET because i need to insert some default values also which come based on file. only the problem is how to map same input value to two different columns of table. please give me the suggestions.
Thanks,
SudhakarFrom what you say:
INSERT tbl(col1, col2)
SELECT col1, col1
FROM OPENROWSET(....)
But I guess it is more difficult. You need to give more details. What sort of data source do you have? What does your query look like? The target table?
Erland Sommarskog, SQL Server MVP, [email protected]
Hi Erland,
Thanks for your response
my source file is text file with | symbol separate for ex:
1002|eTab |V101|eTablet|V100|Logic|LT-7|Laptops|SCM
Database table have columns like
column1,column2,column3...etc, now i need to insert same value from input file into two columns for ex:
the eTab value from text file has to be insert into column2 and column3 of
table
we cannot change format file like below one
for the above situation how can we insert eTab into column2 and column3
Thanks,
Sudhakar. -
Search for column in all tables
I want to search for a column value(example instance_id=123456) in all the tables using one query rather than describing each table to find first if instance id exist and if so do a select from that table.
You could try some sort of variation of this:
DECLARE
value_of_interest NUMBER := 12345;
vTable ALL_TAB_COLS.TABLE_NAME%TYPE;
vExist ALL_TAB_COLS.COLUMN_NAME%TYPE;
BEGIN
DBMS_OUTPUT.PUT_LINE(RPAD('TABLE',45,' ') || ' ' || 'EXISTS');
FOR rec in (SELECT TABLE_NAME FROM ALL_TAB_COLS WHERE COLUMN_NAME='INSTANCE_ID')
LOOP
EXECUTE IMMEDIATE 'SELECT ''' || rec.table_name || ''' AS TAB,DECODE(count(*),0,''NO'',''YES'') AS EXIST FROM '
|| rec.table_name
|| ' WHERE INSTANCE_ID=:value '
|| 'GROUP BY ''' || rec.table_name || '''' INTO vTable,vExist USING value_of_interest;
DBMS_OUTPUT.PUT_LINE(RPAD(vTable,45,' ') || ' ' || vExist);
END LOOP;
EXCEPTION
WHEN NO_DATA_FOUND THEN
DBMS_OUTPUT.PUT_LINE('No Results found!');
END;Please be aware this that has not been tested, and may have to be modified for your use. -
Identifing all ccid columns in all tables
Hi Everyone,
I am in the process of identifying all tables that are either directly storing the CODE_COMBINATION_ID (gl_je_lines.code_combination_Id) or storing the same value with another name (ra_Cust_trx_types_all.GL_ID_REV).
Can the forum experts please advise me few pointers to find the needed data inputs.
Thanks,
SunilHi Sunil,
select * from all_tab_cols
where column_name like '%CCID%'
select * from all_tab_cols
where column_name like '%COMBINATION%'
select * from all_tab_cols
where column_name like '%GL_ID%'
hope these queries meets your requirements
vik -
Fastest way to update column in all tables of schema
In our schema we have two columns ColA and ColB common in all tables in our schema.
Suppose these columns have values as below in all tables
ColA ColB
A1 B11
A12 B22
ABC DEF
Now we have to update ColA and ColB where we have alphanumeric values in all tables, some tables have few hundred records and some tables have millions of records.
Could you gurus suggest me with a fastest way to acheive this.
What we are thinking is to write a procedure where we can input multiple tables which could be updated simultaneously and make a collection within procedure with following values
ColA ColA_R ColB ColB_R
A1 aa B11 bb
A12 aaa B22 bbb
ABC No Update DEF No Update
So whenever we have value matching A1 update it with value aa if we have value matching B11 update it with value bb and so on.
Your inputs are welcome so that to acheive this in fastest manner.
Thanks,
Tony
Edited by: tony29743 on Nov 9, 2010 9:15 AMI would be tempted to do it something like this:
Create an index organized table for the cola updates (old_val, new_val) with a PK on old_val and another one for the colb Values. This could possibliy be a single table, depending on how many distinct values there were for cola and colb and if you are sure that "But if colA and colB have value A1 then it will be updated with aa".
Then do the updates as an updateable join view something like:
UPDATE (SELECT t1.cola, iot.new_val
from tab1 t1, new_values_iot iot
where t1.cola = iot.old_val)
SET cola = new_valThis would require two rounds of updates, one for cola and one for colb, but they could be parallelized somewhat by distributing the tables to be updated through several pl/sql blocks each updating a different set of tables.
You may be able to do it in a single query like:
UPDATE (SELECT t1.cola, t1.colb, iota.new_val new_vala, iotb.new_val new_valb
from tab1 t1, new_values_iot iota, new_values_iot iotb,
where t1.cola = iota.old_val and
t1.cola = iotb.old_val)
SET cola = new_vala,
colb = new_valbHowever, given that you said there were some values in both cola and colb that did not require updating, that may not work since the join will fail on one of cola or colb if that value is not in the IOT, so you will not get all of the rows updated. If, and it is a big if, either both of cola and colb or neither of cola annd colb need to be updated in a single row, it might work. So, looking at your original examples (ABC and DEF do not require updates but A1 does), if there could be as case where cola = 'A1' and colb = 'DEF' then you will have to do it in two updates per table.
John
Maybe you are looking for
-
I have a java applet embeeded into an htm file. I used gif's to serve as my button when its pressed , rolled over, etc... When I try to open this file with internet explorer, the gif's don't show but it does with the applet viewer. This is killing me
-
How to change color of dotted link box when clicked
I've been trying to get the dotted red box around a link image of mine to go away. It shows up when you click on the link (yes, even with border set to none in css). But then I realized this only happens when using Firefox. With Safari, when I click
-
Dear All, My client wants to clear alternative account of a G/L account (Recon account for Asset). For which G/L account's balance must be zero. Can any one please suggest me how to clear balance of recon G/L account. Thanks in Advance! Regards, Nidh
-
Basic question, how to create rtf template with a given xml file
Hello guys I am new to BI publisher and I am learning how to create rtf templates using given xml fiel definitions by following the bi publisher guide The steps I am following is: 1, create template using template builders, which is downloaded into M
-
Please help I'm trying to upgrade to the latest iTunes, but keep getting an error message C:\config.msi\7db625.rbf