How to combine rows from different unrelated tables?
I need to create a report where the data are coming from 2 unrelated tables. My calculation needs data from both tables. Is this possible within Crystal Reports without having to write complicated SQL commands? If not, can someone provide an example of such a query?
thanks in advance
-Mark
Morning Mark,
Yes Amr is right however there has to be some sort of link between the two tables to create a join. For example a Order no from one table matches with other Order no.
There could be another possibility and that is if you have a third table which has two fields common to those two tables then when you bring the third table it will act as a middle man.
If you need to bring the information onto the report according to some sort of criteria then those two tables need to be linked togeather at some point otherwise it won't work.
For example
I have two tables, FOC and Customer, both have nothing in common however the third table Orders has fields which is common to FOC and Customer. So I linked the two tables via Orders table. Now when I open my report my results are based on the Customer and FOC number.
Hope this helps
Regards
Jehanzeb
Similar Messages
-
How to join fields from different internal tables and display into one int
hai i have one doubt...
how to join fields from different internal tables and display into one internal table..
if anybody know the ans for this qus tell me......hii
you can read data as per condition and then can join in one internal table using READ and APPEND statement..refer to following code.
SELECT bwkey " Valuation Area
bukrs " Company Code
FROM t001k
INTO TABLE i_t001k
WHERE bukrs IN s_bukrs.
IF sy-subrc EQ 0.
SELECT bwkey " Valuation Area
werks " Plant
FROM t001w
INTO TABLE i_t001w
FOR ALL ENTRIES IN i_t001k
WHERE bwkey = i_t001k-bwkey
AND werks IN s_werks.
IF sy-subrc EQ 0.
LOOP AT i_output INTO wa_output.
READ TABLE i_t001w INTO wa_t001w WITH KEY werks = wa_output-werks.
READ TABLE i_t001k INTO wa_t001k WITH KEY bwkey = wa_t001w-bwkey.
wa_output-bukrs = wa_t001k-bukrs.
MODIFY i_output FROM wa_output.
CLEAR wa_output.
ENDLOOP. " LOOP AT i_output
ENDIF. " IF sy-subrc EQ 0
regards
twinkal -
How to insert data from different internal table into a data base table
hi all,
I want to insert a particular field in an internal table to a field in a data base table.Note that the fields in the internal table and database table are not of the same name since i need to insert data from different internal tables.can some one tell me how to do this?
in short i want to do something like the foll:
INSERT INTO ZMIS_CODES-CODE VALUE '1'.
*INSERT INTO ZMIS_CODES-COL1 VALUE DATA_MTD-AUFNR .(zmis_codes is the db table and data_mtd is the int.table)REPORT ZINSERT.
tables kna1.
data: itab LIKE KNA1.
data lv_kUNAG LIKE KNA1-KUNNR.
lv_kuNAG = '0000010223'.
ITAB-kuNNR = lv_kuNAG.
ITAB-name1 = 'XYZ'.
INSERT INTO KNA1 VALUES ITAB.
IF SY-SUBRC = 0.
WRITE:/ 'SUCCESS'.
ELSE.
WRITE:/ 'FAILED'.
ENDIF.
Here lv_kunag is ref to kna1 kunnr passed in different name
In internal table .
Try and let me know if this logic dint work. -
How to combine data from different input forms outside a nested iView
Hi,
i try to combine data from different input forms in a single one.
Because of space reasons in Flex compiling i already use nested iViews. Within these nested iViews its possible to use the 'combine' function to do this.
But in the main iView I cant compose these function with other elements. I need to do this because of using these model in Guided Procedures with output parameters. These parameters I only get with a 'endPoint'. Unfortunatly its not possible to combine data from different input forms into the 'endPoint'.
Is there any solution?
Thanx
MathiasHi Scott,
i tried this already and i also tried to map all parameters in the endpoint by drawing lines from the other forms and assign the 'empty parameters' by a formula.
And when i create a collable object in GP and assign the VC iView, only the parameters of the parent-form (the form who trigger the event) are shown as output-parameters.
Maybe any other ideas? I cant believe that such a simple thing is not possible?!?!
In my opinion, thats a bug, that I'am not able to use the combine-operator in the main VC-iView. Whats your mind?
greets
mathias -
How to fetch rows from PL/SQL table(Collections)
Hi,
I retrived rows from the table and stored in to table type.
Now I want fetch these rows and display on the screen. Pls guide me.
following code is my code:
DECLARE
type t1 is table of emp%rowtype index by binary_integer;
var1 t1;
v_counter number:=0;
BEGIN
select * bulk collect into var1 from emp;
for vr in var1.first..var1.last
loop
dbms_output.put_line(var1(1)); --Got an Error Here. Acually I don't Know how to fetch.
update dept set deptno=var1.deptno --Here also Error occured.
end loop;
END;Fetching rows to display them is a task for the client tool. You need to define a ref cursor therefore.
If you just want to play around, here we go
SQL> DECLARE
2 type t1 is table of emp%rowtype index by binary_integer;
3 var1 t1;
4 v_counter number:=0;
5 BEGIN
6 select * bulk collect into var1 from emp;
7 for vr in 1..var1.count loop
8 dbms_output.put_line(var1(vr).ename);
9 update dept set deptno=var1.deptno Here also Error occured.
10 end loop;
11 END;
12 /
SCOTT
ADAMS
PL/SQL procedure successfully completed.
SQL> -
How to fetch data from different standard table to own customize table.
Hi Experts,
I want to develope an INVENTORY TURN OVER REPORT in SAP R/3.As I dont know much about Inventory.I want some one here to guide me regarding this with example so i can develope Inventory Report in R/3.
Also guide me which filed from which table i shud use.What is Inventory Turnover in details and how it is calculated.
Plz reply guys.
Thanks.
Edited by: abhishek.chaturvedi on Aug 9, 2010 8:42 AMHi,
Even iam not sure about it but after looking at your query even i have done some research and got some information for you.
nventory Turnover is a prominent KPI in a lot of businesses. This post will give you some understanding on the concept. In another post I will give details on how the SAP report MC44 can be used to measure inventory turns and what data is used to calculate this ratio.
Formula
Inventory Turnover = Cost of Goods Sold (COGS) / Average Inventory at value
If you are not familiar with the term Cost of Goods Sold, this is the cost of your revenues.
Average Inventory is measured in value and not in volume.
If you divide both elements you know how often you sold youu2019re average inventory. u201CSo what?u201D you ask. I will explain next.
Concept and use
I will present you with two business scenariou2019s to point out the significance of the Inventory Turnover ratio.
Scenario 1
You sell one product. You invest 10.000 EUR as starting stock. You run your business for one year and at then end of the year you are completely sold out. Your revenue accumulates to 12.500 EUR. For simplicity sake your gross profit is 2.500 EUR (12.500 u2013 10.000).
Revenue = 12.500
COGS = 10.000
Average Inventory = 5.000 (10.000 starting stock + 0 end stock / 2 = 5.000 average stock)
Inventory Turnover = 2 (10.000 / 5.000)
ROI = 50% > 2.500 (R-C) earned out of 5.000 (A)
Scenario 2
Again you sell one product. But this time you invest 5.000 EUR in starting stock. After 6 months you sold your stock and you replenish your stock again for 5.000 EUR. After another 6 months youu2019re sold out. Your revenue is again 12.500 EUR. Your gross profit is 2.500 EUR (12.500 u2013 5000 u2013 5000).
Revenue = 12.500
COGS = 10.000
Average Inventory = 2.500 (5.000 starting stock + 0 end stock / 2 = 2.500 average stock)
Inventory Turnover = 4 (10.000 / 2.500)
ROI = 100% > 2.500 (R-C) earned out of 2.500 (A)
cheers,
bhavana -
SUM two fileds from different rows from the same table
I would like to SUM two fileds from different rows from the same table but I don't know how to do that.
E.g.
BillingTransactionsIndex CreateDate UserType UserIndex TransType Reference Total Balance
2 6/5/2008 15:02 1 51 1 150 -288.2 -288.2
5 6/8/2008 11:55 1 51 1 157 -1.58674 -289.787
In the table above I want SUM fields Total and Balance for the first row and the the next row SUM 2nd row Total with 1st row Balance
Please help
ThanksSQL> with tbl as
2 (select 1 as ID, 90 as total from dual
3 union all
4 select 2 as ID, 23 as total from dual
5 union all
6 select 3 as ID, 15 as total from dual
7 union all
8 select 4 as ID, 20 as total from dual)
9 select id , total, sum(total) over (order by ID) as balance from tbl
10 /
ID TOTAL BALANCE
1 90 90
2 23 113
3 15 128
4 20 148
SQL> -
Extract Multiple Rows from a Single Table into a Single Row in a New Table
I have a table in a database that contains contact data like name, address, phone number, etc.
The folks who designed the database and wrote the application wrote it so that all contact records are placed in that table, regardless of contact type. In fact, the contacts table does not even have a column for "type" even though there are many
different types of contacts present in that table.
I am trying to write a mail merge style report in SRSS, that gets sent to a specific type of contact, based on criteria provided that must be obtained from another table, and that data is then used to get back to a specific set of contacts from the contacts
table.
The attached file directly below describes my problem and all related information in an extremely detailed way.
SRSSMailMergeIssue.pdf
Unless there is a way to make a SRSS Tablix point to two different data sets in SRSS, it looks like I have to combine multiple rows from the same table into a new table.
If anyone can review the details in the attached pdf file and possibly point me in the direction I need to run to solve this probelm, I would greatly appreciate it.
I also included a document (below) that shows the tables I reference in the probelm description.
dbtables.pdfI found a solution.... and posted it below
select
dk.ucm_docketnumber [UCM DocketNumber],
dk.ucm_docketid [UCM DocketID],
vc.FirstName [Victim FirstName],
vc.MiddleName [Victim MiddleName],
vc.LastName [Victim LastName],
vc.Suffix [Victim Suffix],
vc.Address1_Line1 [Victim AddressLine1],
vc.Address1_Line2 [Victim AddressLine2],
vc.Address1_Line3 [Victim AddressLine3],
vc.Address1_City [Victim City],
vc.Address1_StateOrProvince [Victim StateProvince],
vc.Address1_PostalCode [Victim Postalcode],
oc.FirstName [Offender FirstName],
oc.MiddleName [Offender MiddleName],
oc.LastName [Offender LastName],
oc.Suffix [Offender Suffix],
oc.Address1_Line1 [Offender AddressLine1],
oc.Address1_Line2 [Offender AddressLine2],
oc.Address1_Line3 [Offender AddressLine3],
oc.Address1_City [Offender City],
oc.Address1_StateOrProvince [Offender StateProvince],
oc.Address1_PostalCode [Offender Postalcode],
pc.FirstName [Arresting Officer FirstName],
pc.MiddleName [Arresting Officer MiddleName],
pc.LastName [Arresting Officer LastName],
pc.Address1_Line1 [Arresting Officer AddressLine1],
pc.Address1_Line2 [Arresting Officer AddressLine2],
pc.Address1_Line3 [Arresting Officer AddressLine3],
pc.Address1_City [Arresting Officer City],
pc.Address1_StateOrProvince [Arresting Officer StateProvince],
pc.Address1_PostalCode [Arresting Officer Postalcode]
FROM ucm_docket dk
left outer join ucm_victim v on dk.ucm_docketid = v.ucm_docketnumber
left outer join contact vc on vc.contactid = v.ucm_victimlookup
left outer join ucm_offender o on o.ucm_offenderid = dk.ucm_offenderlookup
left outer join contact oc on oc.contactid = o.ucm_individualid
left outer join contact pc on pc.contactid = dk.ucm_ArrestingOfficerLookup
WHERE (dk.ucm_docketnumber = @DocketNUM) -
Fetch data from different database tables
Hi...
How can i fetch data from different database tables and put it into a internal table and then display it??? Can provide simple short codes as i'm new to ABAP. Thanks.Hi,
Check this sample code..
TYPE-POOLS: slis.
DATA: BEGIN OF itab OCCURS 0,
vbeln TYPE vbeln,
expand,
END OF itab.
DATA: BEGIN OF itab1 OCCURS 0,
vbeln TYPE vbeln,
posnr TYPE posnr,
matnr TYPE matnr,
netpr TYPE netpr,
END OF itab1.
DATA: t_fieldcatalog TYPE slis_t_fieldcat_alv.
DATA: s_fieldcatalog TYPE slis_fieldcat_alv.
s_fieldcatalog-col_pos = '1'.
s_fieldcatalog-fieldname = 'VBELN'.
s_fieldcatalog-tabname = 'ITAB'.
s_fieldcatalog-rollname = 'VBELN'.
s_fieldcatalog-outputlen = '12'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '1'.
s_fieldcatalog-fieldname = 'VBELN'.
s_fieldcatalog-tabname = 'ITAB1'.
s_fieldcatalog-rollname = 'VBELN'.
s_fieldcatalog-outputlen = '12'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '2'.
s_fieldcatalog-fieldname = 'POSNR'.
s_fieldcatalog-tabname = 'ITAB1'.
s_fieldcatalog-rollname = 'POSNR'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '3'.
s_fieldcatalog-fieldname = 'MATNR'.
s_fieldcatalog-tabname = 'ITAB1'.
s_fieldcatalog-rollname = 'MATNR'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
s_fieldcatalog-col_pos = '4'.
s_fieldcatalog-fieldname = 'NETPR'.
s_fieldcatalog-tabname = 'ITAB1'.
s_fieldcatalog-rollname = 'NETPR'.
s_fieldcatalog-do_sum = 'X'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
DATA: s_layout TYPE slis_layout_alv.
s_layout-subtotals_text = 'SUBTOTAL TEXT'.
s_layout-key_hotspot = 'X'.
s_layout-expand_fieldname = 'EXPAND'.
SELECT vbeln UP TO 100 ROWS
FROM
vbak
INTO TABLE itab.
IF NOT itab[] IS INITIAL.
SELECT vbeln posnr matnr netpr
FROM vbap
INTO TABLE itab1
FOR ALL ENTRIES IN itab
WHERE vbeln = itab-vbeln.
ENDIF.
DATA: v_repid TYPE syrepid.
v_repid = sy-repid.
DATA: s_keyinfo TYPE slis_keyinfo_alv.
s_keyinfo-header01 = 'VBELN'.
s_keyinfo-item01 = 'VBELN'.
CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
EXPORTING
i_callback_program = v_repid
is_layout = s_layout
it_fieldcat = t_fieldcatalog
i_tabname_header = 'ITAB'
i_tabname_item = 'ITAB1'
is_keyinfo = s_keyinfo
TABLES
t_outtab_header = itab
t_outtab_item = itab1
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Thanks
Naren -
How to move data from a staging table to three entity tables #2
Environment: SQL Server 2008 R2
I have a few questions:
How would I prevent duplicate records, when/ IF SSIS is executed many times?
How would I know that all huge volume of data being loaded in the entity tables?
In reference to "how to move data from a staging table to three entity tables ", since I am loading large volume of data, while using lookup transformation:
which of the merge components is best suited.
How to configure merge component correctly. (screen shot is preferred)
Please refer to the following link
http://social.msdn.microsoft.com/Forums/en-US/5f2128c8-3ddd-4455-9076-05fa1902a62a/how-to-move-data-from-a-staging-table-to-three-entity-tables?forum=sqlintegrationservicesYou can use RowCount transformation in the path where you want to capture record details. Then inside rowcount transformation pass a integer variable to get count value inside
the event handler can be configured as below
Inside Execute SQL task add INSERT statement to add rowcount to your audit table
Can you also show me how to Check against destination table using key columns inside a lookup task and insert only non
matched records (No Match output)
This is explained clearly in below link which Arthur posted
http://www.sqlis.com/sqlis/post/Get-all-from-Table-A-that-isnt-in-Table-B.aspx
For large data I would prefer doing this in T-SQL. So what you could do is dump data to staging table and then apply
T-SQL MERGE between tables (or even a combination of INSERT/UPDATE statements)
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs -
How to export data from a Oracle table to a delimited file?
I know how to load delimited file into a table, but how to export
data from a Oracle table to a delimited file?
Thanks in advance.Try looking at this link, it's long but there's three different solutions discussed in it. If you look at Barbara Boehmer's
solution in her posts in the link below you'll see that she's addressed your concerns with spool files.
Re: utl_smtp and triggers -
Deleting a row from the item table
Hi All,
I have a requirement where I need to put a button to delete the selected row from the item table and for this I have written the following code:
DATA lo_nd_t_bseg TYPE REF TO if_wd_context_node.
DATA lo_el_t_bseg TYPE REF TO if_wd_context_element.
DATA ls_t_bseg TYPE wd_this->element_t_bseg.
data: it_tab type table of wd_this->element_t_bseg.
lo_nd_t_bseg = wd_context->path_get_node( path = `Z.T_BSEG` ).
lo_el_t_bseg = lo_nd_t_bseg->get_element( ).
lo_el_t_bseg->get_static_attributes(
IMPORTING
static_attributes = ls_t_bseg ).
lo_nd_t_bseg = wd_context->path_get_node( path = `Z.T_BSEG` ).
lo_el_t_bseg = lo_nd_t_bseg->get_element( ).
IF lo_el_t_bseg IS not INITIAL.
lo_nd_t_bseg->remove_element( lo_el_t_bseg ).
ENDIF.
Now the problem is although it's deleteing the selected line correctly but because of this I am losing one line on the screen for the user to enter... my form has a fixed number of lines and in my case it's 10... so everytime I am using deleting a line item I am losing one line to enter..... can you please tell me how can I avoid this?
Edited by: rajatg on Aug 4, 2011 3:12 PMlets say...
i have 1,2,3 documents
i have cleared , document 2....
1. when the user selects this record.... you can read the context_element....using the context element you can get the values and clear those values and set the blank values...
when the user click on save ...you can have only those two records in the table.
2. conitnue with your logic .... remove_element. once it is done ,,, create_element at the deleted index...
3. when clicked on delete ...remove_element ( current code).... bind the table to the node... and you will have ur values -
OBIEE 11g - Combine data from two Oracle tables
Good day!
I tried to combine data from two Oracle tables as fact data, but it doesn't work.
My steps: I created SCOTT.EMP2 table from SCOTT.EMP table, update EMPNO and ENAME values of EMP2 table to distinguish data of my tables. Then I imported physical tables DEPT, EMP and EMP2 to BIEE 11g, created joins DEPT-EMP and DEPT-EMP2 in physical diagram. Then I dragged DEPT and EMP tables to BMM, and EMP2 table to EMP as second LTS. In Content tab for EMP and EMP2 I checked "This source should be combined with other sources at this level" checkboxes. Then I renamed logical tables EMP and DEPT to Employees and Departments and dragged them to Presentation area. In Answers I created Analysis with columns DNAME and ENAME.
The problem is that data on results tab is only from one physical table EMP or EMP2 (depending on the order of sources EMP and EMP2 of LT Employees) and not from both.
Can anybody help? Am I missed something?
Al.Hi Al,
I think you have to define the content of the LTS.
http://download.oracle.com/docs/cd/E12096_01/books/admintool/admintool_BusModSetup16.html
You have to specify the content of the different fragments.
http://download.oracle.com/docs/cd/E12096_01/books/admintool/admintool_SetUpAggNav3.html#wp1005333
Maybe you have to add an additional column 'Source' ('EMP1', 'EMP2')
Good Luck,
Daan Bakboord
http://obibb.wordpress.com -
Finding missed sequence numbers and rows from a fact table
Finding missed sequence numbers and rows from a fact table
Hi
I am working on an OLAP date cube with the following schema:
As you can see there is a fact transaction with two dimensions called cardNumber and Sequence. Card dimension contains about three million card numbers.
Sequence dimension contains a sequence number from 0 to 255. Fact transaction contains about 400 million transactions of those cards.
Each transaction has a sequence number in 0 to 255 ranges. If sequence number of transactions of a card reaches to 255 the next transaction would get 0 as a sequence number.
For example if a card has 1000 transactions then sequence numbers are as follows;
Transaction 1 to transaction 256 with sequences from 0 to 255
Transaction 257 to transaction 512 with sequences from 0 to 255
Transaction 513 to transaction 768 with sequences from 0 to 255
Transaction 769 to transaction 1000 with sequences from 0 to 231
The problem is that:
Sometimes there are several missed transactions. For example instead of sequence from 0 to 255, sequences are from 0 to 150 and then from 160 to 255. Here 10 transactions have been missed.
How can I find all missed transactions of all cards with a MDX QUERY?
I really appreciate for helpsThank you Liao
I need to find missed numbers, In this scenario I want the query to tell the missed numbers are: 151,152,153,154,155,156,157,158,159
Relative transactions are also missed, so I think it is impossible to get them by your MDX query
Suppose this:
date
time
sequence
20140701
23:22:00
149
20140701
23:44:00
150
20140702
8:30:00
160
20140702
9:30:00
161
20140702
11:30:00
162
20140702
11:45:00
163
As you can see the sequence number of the last transaction at the 20140701 is 150
We expecting that the first transaction of the next day should be 151 but it is 160. Those 10 transactions are totally missed and we just need to
find missed sequence numbers -
Randomly selecting some rows from the database table
Hi can some one help me in selecting some rows from a database table which has around 90,000 rows.
Thanks.One thing you might try is the "sample" clause if you have 8i which is supposed to return a random percentage of the table. Say for example, you have a sequence number on your table as the pkey. Then you might try:
select * from <table_name> where pkey in(select pkey from <table_name> sample(10));
This should give you a random 10 percent of the rows in the table but I tried this once and the results seemed unpredictable. For example it returned a different number of rows each time even though the number of rows in the table didn't change.
Hope this works for you.
Maybe you are looking for
-
Asset Year End Closing AJRW & AJAB
1) After running AJRW, can users still post assets under previous year ? 2) Any time-dependent for AJAB and AJRW ? Should Run AJRW 1st or AJAB ?
-
Qosmio G20-107 frozen while surfing
Hi, I have had a problem yesterday while surfing on the net : The machine stopped responding (frozen) and then Ive heard a long (for 20secs or more) bip. Then I had to reboot the machine by pressing the on/off button. It's shut down, but It didn't bo
-
Hi all, I would like to use UNICODE font in my SmartForm (for Czech language (republic czhec country) ) but in there is only the ANDALE_J ( _K _S _T ) fonts available... Does anothers fonts exist or it is possible to create a new one (by SE73)? Many
-
Imessage doesnt send imessages to someone with ios5, only sms texts
When I try sending an iMessage to someone with iOS 5, they don't receive it. When they send it to me, I receive it as an SMS text. I tried sending to another iPhone and iMessage worked, as did SMS text with a non-iPhone. Why is this happening? It's r
-
Installing Older Software Help
Hi, I have a set of Photoshop filters that worked fine with OSX 10.4.x. I just went to install them on my newer iMac with Leopard and the default opener is QUicktime which recognizes it as a movie, of which it's not and says, sorry not a movie..... I