Listing the Data of two tables to do a DistinctCount
Post Author: Judith
CA Forum: Formula
Hi there,
I feel really daft, when I am looking at the other entries. It makes me very new to the entire surrounding. I have been working on Crystal Reports for two weeks now and I haven't got an inkling of what I am doing. I would very much appreciate some help:
I have peoples' names in two lists and I would like to do a distinct count as if it was one list...
Can't be that difficult, but I haven't figured out, how it is done. Can anyone help?
Judith
Post Author: Judith
CA Forum: Formula
Hi there, they are Names Lists coming from the same Excel Sheet. Names A and Names B. They contain the same names though and I just want to treat them as if they were one list. If I do {Item 1} & {Item 2} it simply seems to place them next to each other as in
Tom AlexFiona Tom
but not as one list like e.g.
TomAlexFionaTom
So if I would like to see a distictcount, it looks at distinct pairs and not the number of distinct names.
Thanks a lot for your help!
Judith
Similar Messages
-
Insert the data into two tables at a time.
Hi ,
i have these two tables
create table [dbo].[test1](
[test1_id] [int] identity(1,1) primary key,
[test2_id] [int] not null
create table [dbo].[test2](
[test2_id] [int] identity(1,1) primary key,
[test1_id] [int] not null
alter table [dbo].[test1]
add constraint [fk_test1_test2_id] foreign key([test2_id])
references [dbo].[test2] ([test2_id])
alter table [dbo].[test2] add constraint [fk_test2_test2_id] foreign key([test1_id])
references [dbo].[test1] ([test1_id])
I want to insert the data into two tables in one insert statement. How can i do this using T-SQL ?
Thanks in advance.You can INSERT into both tables within one Transaction but not in one statement. By the way, you would need to alter your dbo.Test1 table to allow null for first INSERT test2_id column
See sample code below:
CREATE TABLE #test1(test1_ID INT IDENTITY(1,1),test2_id INT NULL)
CREATE TABLE #test2(test2_ID INT IDENTITY(1,1),test1_ID INT)
DECLARE @Test1dentity INT
DECLARE @Test2dentity INT
BEGIN TRAN
-- Insert NULL as test2_ID value is unknown
INSERT INTO #test1(test2_ID)
SELECT NULL;
-- get inserted identity value
SET @Test1dentity = SCOPE_IDENTITY();
INSERT INTO #test2(test1_ID)
SELECT @Test1dentity;
-- get inserted identity value
SET @Test2dentity = SCOPE_IDENTITY();
-- Update test1 table
UPDATE #test1
SET test2_ID = @Test2dentity
WHERE test1_ID = @Test1dentity;
COMMIT
SELECT * FROM #test1;
SELECT * FROM #test2;
-- Drop temp tables
IF OBJECT_ID('tempdb..#test1') IS NOT NULL
BEGIN
DROP TABLE #test1
END
IF OBJECT_ID('tempdb..#test2') IS NOT NULL
BEGIN
DROP TABLE #test2
END
web: www.ronnierahman.com -
To Select the data from two table one is transp table and onther is cluster
Hi All,
I want to select the data from two tables
Here i am giving with an example.
Fileds: kunnr belnr from bseg. table bseg
fields: adrnr from kna1 table: kna1.
Know i want to put these into one internal table based on kunnr and belnr.
Thanks in advance.
RameshHi,
U cant use joins on cluster table and BSEG is a cluster table so use FOR ALL ENTRIES for taht
refer this code
*& Form sub_read_bsak
text
--> p1 text
<-- p2 text
FORM sub_read_bsak.
*--Select data from BSAK Table
SELECT lifnr
augdt
augbl
gjahr
belnr
xblnr
blart
dmbtr
mwskz
mwsts
sgtxt
FROM bsak
INTO CORRESPONDING FIELDS OF TABLE it_bsak
WHERE belnr IN s_belnr
AND augdt IN s_augdt.
IF sy-subrc EQ 0.
*--Sort table by accounting document and vendor number
SORT it_bsak BY belnr lifnr.
ENDIF.
ENDFORM. " sub_read_bsak
*& Form sub_read_bseg
text
--> p1 text
<-- p2 text
FORM sub_read_bseg.
IF NOT it_bsak[] IS INITIAL.
*--Select data from BSEG table
SELECT belnr
gjahr
shkzg
kostl
hkont
ebeln
ebelp
FROM bseg
INTO CORRESPONDING FIELDS OF TABLE it_bseg
FOR ALL ENTRIES IN it_bsak
WHERE belnr EQ it_bsak-belnr
AND gjahr EQ it_bsak-gjahr
AND shkzg EQ 'S'.
IF sy-subrc EQ 0.
*--Sort table by accounting document
SORT it_bseg BY belnr.
ENDIF.
ENDIF.
ENDFORM. " sub_read_bseg -
Fetch the data from two tables
hell all
i want to fetch the data from two tables, one is from internal table and another one is data base table. what syntax i have to use either FOR ALL ENTRIES or INNER JOIN?hi
Use FOR ALL ENTRIES.
see the sample code
select * into table tvbrk from vbrk
where fkart in ('F2', 'F3', 'RE',
'ZVEC' , 'ZVEM' , 'ZVED',
'S1')
and erdat in so_erdat
and kunag in s_kunag.
erdat in so_erdat
and fkart in ('F2', 'F3', 'RE',
'ZVEC' , 'ZVEM').
if not tvbrk is initial.
select * into table t_zregion from zregion
for all entries in tvbrk
where country = tvbrk-land1
and region = s_regio.
endif.
thanks
sitaram -
Query the data between two tables
Need help for query the data between two tables
Table 1: Time sheet
P.ID P.Name EmpID HoursSpend DateTime
c12234 Test 25 4 06/12/2013
c12234 Test 25 7 06/13/2013
c12234 Test 25 8 06/15/2013
c12234 Test 5 3 06/21/2013
c12234 Test 2 5 07/15/2013
c12234 Test 25 4 07/21/2013
Table 2: cost table
EmpID FromDate ToDate Rate
25 05/01/2013 06/30/2013 250
2 04/01/2013 05/31/2013 150
25 07/01/2013 09/30/2013 300
Output
P.ID P.Name EmpID HoursSpend DateTime Rate Total (HoursSond x Rate)
c12234 Test 25 4 06/12/2013 250 1000 (4*250)
c12234 Test 25 7 06/13/2013 250 1750
c12234 Test 25 8 06/15/2013 250
2000
c12234 Test 25 4 07/21/2013 300
1200
c12234 Test 2 5 07/15/2013 150
750
===========================================
Total 28
6700
============================================
Here EmpID =2 don't have rate in the cost table on july month should be pick from last entry from cost table.Hi Gopal,
According to your description, it seems that the output needn’t include the row when EmpID=2. Because the DateTime for it in Table1 doesn’t included between FromDate column and ToDate column. After testing the issue in my environment, we can refer to the
query like below to achieve your requirement:
SELECT time.*,cost.EmpID,cost.Rate,(time.HoursSpend * cost.Rate)as [Total (HoursSond x Rate)]
FROM [Time sheet] as time
INNER JOIN
[cost table]as cost
ON time.EmpID = cost.EmpID
AND time.DateTime BETWEEN cost.FromDate AND cost.ToDate
If there are any other questions, please feel free to ask.
Thanks,
Katherine Xiong
Katherine Xiong
TechNet Community Support -
Not saving the data in two tables
Hello,
its my production problem, i have an update form where you can update the records and these
records will sit in the temp tables until the final approval from the supervisor.
In this update form i have two table where i am saving the data one is dup_emp to save the
officer data and another is the dup_address to save the officer where he worked data.
in this form address form is pop up screen where you can update and gets back to the original
form where you can see all the other fields. my problem is if a user hit the cancel button on
address form example the user doesnt want to update any information on that screen so user
cancel that screen, and comes to the other screen where the user makes the changes to the
appropriate fields and hits the SAVE button. in this case its saving only to the dup_emp table
data not the address data from the address form to dup_address table for the same record.
if the user cancels in both the screens cancel button it should delete the record from both the
tables but cancel in form and saves in another form it should save the record in both the
tables.
here is my code from both cancel buttons from both the forms.
this is code is from address form cancel button.
delete from dup_address
where address_id=:address_id
and parent_table_name='emp';
commit;
CLEAR_BLOCK;
go_block('DUP_EMP');
This code is from dup form of the cancel button
declare
temp_address_id varchar2 (12);
begin
delete from dup_emp
where secondemp_id =:dup_emp.secondemp_id;
delete from dup_address
where parent_t_id=:global.secondemp
and parent_table_name='emp';
commit;
clear_block;
go_block('secondaryemp');
END;Hi,
As Aravind mentioned, it's nothing related to workflow. You have to find a BADI in tcode PA30 that could be used after the infotype is updated. So, you can use FM SAVE_TEXT.
Regards, -
Joining the data from two Tables
I create a table with six months date from Jan to Jun. Another table with July trough Sept.
Now I want one table in which I am going to at the end of the year have all 2007 fiscal data.
I do not want to restore them ever back to the components. How do I do this?If I understand you correctly, I think you merely want to enlarge the first table enough to accommodate the data from the second table. Then select the cells in the second table and copy and paste them into the newly created space in the first table. Ask if you need more detail instructions on how to do this.
-
Data from two tables in the same row in XML transformation
Hi,
I am using XML transformation for generating excel file which is to besent as email attachment.
Here I want to display the data from two internal tables in the same row in the excel. .I am using <tt:loop ref=".<table name>"> ... </tt:loop> for looping through the table. Can I loop two table simultaneously ? In that case how will I specify the fields in each table . Some of the fields in two tables are of same name and type.
Please help...
Thanks,
JissaHello Brian,
Thank you for your answer. It is approach I will use, I think. However let me ask: Would it be possible to have a Version in this layout, too? I mean to see, which value comes from Version A and which comes from Version B? Something like this:
Calendar Month Version Sales Amount
2011.01 B 200
2011.02 B 300
2011.03 A 260
2011.04 A 230
2011.05 A 200
A -
Saving the data from two info path forms in to a single list in share point 2010
Hi ,
I have two info path forms are in share point page FM 1 and FM 2.
In FM 1 I am getting data from lists by using drop down and casket drop down and FM 2 i need to enter manually after entering
i want to save both forms information(FM 1 & FM 2 ) in to a single list of share point 2010
If any knows the solution please reply me
Thanking You,
Arun DarlyHi,
Based on your description, my understanding is that you want to save the data from two info path forms in to a single list in share point 2010.
We can't save the data from two info path forms in to a single list, but we can
save the data from two info path forms in to a single library.
Open the FM 1 and FM 2 in Infopath(you have save it Locally once).
Publish the FM 1 and FM 2 as content types named FM 1 and FM 2.
Add the content types FM 1 and FM 2 into a document library, Then you can save the data
from two info path forms in to a single library.
Best Regards,
Lisa Chen
Lisa Chen
TechNet Community Support -
Can we get the data from two internal tables in ALV.
hi friends i would like to display the data using two internal tables using alv grid.please guide me.
Hi,
ALV would be having a specific layout say :
MATNR
MAKTX
QTY
Now, if you have two internal tables, then do they have a different structure. If they have different structures, then what kind of ALV layout you expect. The ALV output should be as per the structure of 1st or 2nd internal table.
If both internal table have same layout, then populate the data from 2nd internal table into 1st internal table and pass the 1st internal table ( it will have data of both internal tables) to ALV.
Best regards,
Prashant -
Intervals, synchronize the data between two oracle tables located in diffe
Hi Experts,
Is there any way I can, at set intervals, synchronize the data between two oracle tables located in different servers? What is the software, if there is any? If there are steps I can follow, so much the better.
Thanks!I'm not sure what you want to achieve here...
I want to synchronize both the Servers , so that it can update HO servers as well as Factory Server with the complete data. Could you please elaborate a little bit more; basing on your description I could also tell you how to setup timesync for those two servers if I understand "complete data" as the current date and time...
Also a lot of solutions are platform and version specific so it would help if you could indicate OS and Database Versions (4 digit).
And I still fail to see what this has to do with forms. You might want to post your question to the Database General forum: General Database Discussions
cheers -
Hi
how to create a external content type for Read and Update data from two tables in sqlserver using sharepoint designer 2010
i created a bcs service using centraladministration site
i have two tables in sqlserver
1)Employee
-empno
-firstname
-lastname
2)EmpDepartment
-empno
-deptno
-location
i want to just create a list to display employee details from two tables
empid firstname deptno location
and same time update in two tables
adilWhen I try to create an external content type based on a view (AdventureWorks2012.vSalesPerson) - I can display the data in an external list. When I attempt to edit it, I get an error:
External List fails when attached to a SQL view
Sorry, something went wrong
Failed to update a list item for this external list based on the Entity (External Content Type) 'SalesForce' in EntityNamespace 'http://xxxxxxxx'. Details: The query against the database caused an error.
I can edit the view in SQL Manager, so it seems strange that it fails.
Any advice would be greatly GREATLY appreciated.
Thanks,
Randy -
Question about retrieving data from two tables
Hi everyone.
I've been working on this and was wondering what the correct way of handling this would be.
I have two tables, a Billing Table that contains invoices and related information, and a Payments Table that contains payments and related information to that.
Both tables contain a Date Column for the date that the Invoice was generated or the Payment was made.
I want to get a list of all Invoices and the respective payments if the invoice was generated between two dates OR the payment was made between these two dates.
I can get a list of the invoices and their payments if the invoice was generated between those dates. I can get a list of the payments if they were made between those dates. But I can't seem to figure out how to do both.
How do I Join two tables and have it return the data from both tables if either meets the required Date Period?
Here is the SQL that I have so far. This SQL returns all of the Invoices and Payments IF the Invoice was generated between these two dates (Or updated).
SELECT Billing.ID AS [BID], Billing.AttachmentName, Billing.BillingType, Billing.Invoice, Billing.Description, Billing.Amount, Billing.DateCreated AS [BillingDate],
Payments.ID AS [PID], Payments.Type AS PaymentType, Payments.Payment, Payments.PaymentNote, Payments.Reason AS [BillReason], Payments.DateCreated AS [PaymentDate],
Customers.ID AS [CID], COALESCE(NULLIF(Customers.Company,'') + ' - ','') + Customers.LName + ', ' + Customers.FName AS [Name],
Jobs.ID AS [JID], Jobs.JobType, Jobs.JobStatus, Jobs.JobStatusDate
FROM Billing LEFT OUTER JOIN Payments ON Payments.BillingID = Billing.ID
RIGHT OUTER JOIN Customers ON Customers.ID = Billing.CustomerID
RIGHT OUTER JOIN Jobs ON Jobs.ID = Billing.JobID
WHERE
Billing.BillingType = 'Invoice' AND Billing.PaidInFull = 'No' AND Billing.Collections = 'No' AND Billing.ChargeOff = 'No' AND Billing.Lien = 'No' AND Billing.InvoiceCanceled = 'No'
AND (Billing.DateCreated >= '1/1/2014' AND Billing.DateCreated <= '8/13/14') OR (Billing.DateUpdated >= '1/1/14' AND Billing.DateUpdated <= '8/13/14')
ORDER BY Name Asc, Billing.Invoice, PID
Thanks for your help, I really appreciate it.
-Matt-I don't quite follow your query, but your description leads me to think that you need the set of Billing IDs for bills that were created as defined or that have payments that were created as defined. From that set of IDs you then simply want all Bills
and their associated payments. So how do you get that set of IDS? One way is the union operator:
with allbill (billID) as (
select ID from dbo.Billings where DateCreated between ...
union
select BillingID from dbo.Payments where DateCreated between ... )
select ...
from allbill inner join dbo.Billings as bill on allbill.billID = bill.ID inner join dbo.Payments as pay
on bill.ID = pay.BillingID
order by ... ;
Your description leads me to believe that you query is much more complicated, but the basic idea is the union in the CTE - generate one combined set of bill IDs that identify all your bills of interest. Note that I assumed that a payment cannot exist
with an associated billing. -
Transaction to see common data between two tables
Is there any transaction to see common data between two tables with out creating views.
what is the transaction to see the link between two tables
regards
pavanHi,
Go to a transparent table for which you want to know the common fields, from there click the button GRAPHICS (shortcut Ctrl + Shift + F11) in the application tool bar. Then you are redirected to a list containing the tables belonging to the same group. There select whatever tables you would like to see and click COPY. A window will pop-up and will show the relationship between the fields of the tables in a flow chart format.
see to this link also.
Common fields b/w tables
Regards,
Revathi Bhoopal. -
How to dynamically display the data from a table base on row selection of another table in ADF
Hi ,
I have a requirement in ADF. I need to change the data of a table based on row selection of another Table . Both the table have a Parent Child relationship between them. They have a common attribute say department_id.
For this I created bind variable in view object of employees table and wrote a where clause in the sql query using that bind variable. Then I created method for selection listener of department Table in java bean.
My method is following
public void onrowselection(SelectionEvent selectionEvent) {
RichTable richTable = (RichTable)selectionEvent.getSource();
CollectionModel tableModel = (CollectionModel)richTable.getValue();
JUCtrlHierBinding adfTableBinding = (JUCtrlHierBinding)tableModel.getWrappedData();
Object selectedRowData = richTable.getSelectedRowData();
JUCtrlHierNodeBinding nodeBinding = (JUCtrlHierNodeBinding)selectedRowData;
oracle.jbo.domain.Number newVal = (oracle.jbo.domain.Number) nodeBinding.getAttribute("DepartmentId");
Number pallet = newVal.bigDecimalValue();
System.out.println("Selected values " + pallet);
BindingContext bindingctx = BindingContext.getCurrent();
BindingContainer bindings = bindingctx.getCurrentBindingsEntry();
DCBindingContainer bindingsImpl = (DCBindingContainer) bindings;
DCIteratorBinding dciter = bindingsImpl.findIteratorBinding("EmployeesView1Iterator");//access the iterator by its ID value in the PageDef file
ViewObject vo =dciter.getViewObject();
vo.setNamedWhereClauseParam("DepartmentId", pallet);//enter your value
vo.executeQuery();
It is printing the selected value of department id from department table in the log. But it is not able to pass the value to employees view. It is showing the following error in the log
"Definition DepartmentId of type Variable is not found in EmployeesView1."
I will be very thankful if someone helps me to solve this errror or is there any other way to achieve the same requirement.
Thanks
NileshNote quite sure why you simply wont create a viewlink for the viewobject the tables are based on..
The viewlink attribute will be based on the departmentId and it's a simple master detail relationship which automatically uses ppr.
However, if both tables are on the same page; using your hack about;
On the underlying viewobject, define a viewcriteria e.g. "listById" and set your bind variable here.
I would bind table two to a RichTable component:
RichTable t2;
public void onrowselection(SelectionEvent selectionEvent) {
RichTable richTable = (RichTable)selectionEvent.getSource();
CollectionModel tableModel = (CollectionModel)richTable.getValue();
JUCtrlHierBinding adfTableBinding = (JUCtrlHierBinding)tableModel.getWrappedData();
Object selectedRowData = richTable.getSelectedRowData();
JUCtrlHierNodeBinding nodeBinding = (JUCtrlHierNodeBinding)selectedRowData;
oracle.jbo.domain.Number newVal = (oracle.jbo.domain.Number) nodeBinding.getAttribute("DepartmentId");
Number pallet = newVal.bigDecimalValue();
System.out.println("Selected values " + pallet);
refreshTable2(pallet);
BindingContext bindingctx = BindingContext.getCurrent();
BindingContainer bindings = bindingctx.getCurrentBindingsEntry();
DCBindingContainer bindingsImpl = (DCBindingContainer) bindings;
DCIteratorBinding dciter = bindingsImpl.findIteratorBinding("EmployeesView1Iterator");//access the iterator by its ID value in the PageDef file
ViewObject vo =dciter.getViewObject();
vo.setNamedWhereClauseParam("DepartmentId", pallet);//enter your value
vo.executeQuery();
private void refreshTable2(Number pallet){
RichTable x=getT2();
CollectionModel cm=(CollectionModel)x.getValue();
JUCtrlHierBinding jcb=(JUCtrlHierBinding)cm.getWrappedData();
BindingContainer bindings = bindingctx.getCurrentBindingsEntry();
DCBindingContainer bindingsImpl = (DCBindingContainer) bindings;
DCIteratorBinding dciter = bindingsImpl.findIteratorBinding(jcb.getName()+"Iterator");
ViewObject vo =dciter.getViewObject();
ViewCriteriaManager vcm=vo.getViewCriteriaManager();
ViewCriteria vc=vcm.getViewCriteria("listById");
vo.applyViewCriteria(vc);
vo.setNamedWhereClauseParam("DepartmentId",pallet);
vo.executeQuery();
AdfFacesContext.getCurrentInstance().addPartialTarget(getT2());
Maybe you are looking for
-
How do i locate my stolen mac book
My Mac Book was stolen this friday, in Chelsea Bridge London, How do I locate it?
-
How do I get my bought music to work as ringtone?
How do I get my bought music to work as ringtones?
-
Apex 3.2 I have an updateable report that requires one of the columns to have a pop up calendar, displaying date and time. My sql for the column is currently APEX_ITEM.DATE_POPUP(7,null,a.export_time,'dd.mm.yyyy hh:mi:ss') I have also tried APEX_ITEM
-
Hey, I seem to have this problem with Illustrator where all my defaults are upside down and backward. For example, everytime I start a text box, the text starts upside down in the bottom right corner moving to the left. Is this a preset that I can ch
-
Captivate 5.5 SLOW Saves
FORUM POST Original project in Captivate 5 is 56.9 MB Save time: 18 to 30 seconds (depending on number of windows and other activity on system) Saved file size in Captivate 5.5 is 49.6 MB (opened CPT v5 file and "saved as" CPTX v5.5) Save time: 8 min