Query between two Datatables
Hello
I'm very new to using Datasets and Datatables so forgive my ignorance; I have extensively searched through the forums but am having problems working out the best way forward. I have two Datatables in an application which are derived from an SQL Data Connection
using stored SQL queries. The two tables are dtIncrementComplianceManagers and dtIncrementCompliance.
At run time, I need the application loop through the rows of dtIncrementComplianceManagers and each time create a new datatable which contains all the rows in dtIncrementCompliance that share the ManagerEmail field with the current row in dtIncrementComplianceManagers .
This would be used to compose an email to the manager regarding their staff and the application would then move on to the next manager.
As an SQL query it would look like this
SELECT A.*
FROM dtIncrementComplianceas A, dtIncrementComplianceManagers as B
WHERE A.ManagerEmail = B.ManagerEmail
I'm not sure how to user a query of the existing datatables to populate a new table. This is where it would be located:
Public Sub RunManagerEmails()
Me.DtIncrementComplianceManagersTableAdapter.Fill(Me.HRRecruitmentDataSet.dtIncrementComplianceManagers)
Me.DtIncrementComplianceTableAdapter.Fill(Me.HRRecruitmentDataSet.dtIncrementCompliance)
For Each Row As DataRow In HRRecruitmentDataSet.dtIncrementComplianceManagers.Rows
<-----NEW CODE TO GO HERE---->
Next Row
End Sub
Any help would be much appreciated.
Hello Leo,
>>I'm not sure how to user a query of the existing datatables to populate a new table. This is where it would be located
You could use LINQ to DataSet which has a similar syntax with SQL query:
LINQ to DataSet
In your case, you could perform a JOIN operation:
Query Expression Syntax Examples: Join Operators (LINQ to DataSet)
For storing the result to a new datatable, you could use the CopyToDataTable:
https://msdn.microsoft.com/en-us/library/bb386921(v=vs.110).aspx
Regards.
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey.
Similar Messages
-
Select Query Between two dates...
Hi Guru's,
I need a Select Query between two dates, also if the record not found for any in between date then it should return NULL or 0 ...
for Example
1. I am having two records in DB for date 2-10-2008 & 4-10-2008
2. Now suppose I have given Query for date between 1-10-2008 to 5-10-2008
Then it should return me 5 records with valid values for 2 & 4 and NULL for other 1,3,5
Thanks.Try like this:
with
t as
select date '2008-10-02' as dt, 'Record #1 (in DB)' as str from dual union all
select date '2008-10-04' as dt, 'Record #2 (in DB)' as str from dual
select v.dt, t.str
from (
select date '2008-10-01' + level - 1 as dt
from dual
connect by level <= (date '2008-10-05' - date '2008-10-01') + 1
) v
left join t
on v.dt = t.dt
order by 1 -
Query between two date columns ?
Oracle 11g R2
I'm trying too create a query between two date columns. I have a view that consists of many columns. There are two columns in question called valid_to and valid_from
Part Number Valid_from valid_to
100 01/01/2000 01/01/9999
200 01/01/2000 01/01/9999
300 01/01/2000 01/01/9999
etc
If I want to only see rows between with a date range of 01/01/2000 and 01/01/2013 how can I put this as SQL ?
Thanks in advanceHi,
Whenever you have a problem, please post a little sample data (CREATE TABLE and INSERT statements, relevant columns only), so that the people who want to help you can re-create the problem and test their ideas.
Also post the results you want from that data, and an explanation of how you get those results from that data, with specific examples.
See the forum FAQ: https://forums.oracle.com/message/9362002
If you want to find rows that have that exact range, then you can do something like
SELECT *
FROM table_x
WHERE valid_from = DATE '2000-01-01
AND valid_to = DATE '2013-01-01'
If you want to find rows where any or all or the range on the row overlaps any or all of the 200-2013 target range, then
SELECT *
FROM table_x
WHERE valid_from <= DATE '2013-01-02
AND valid_to >= DATE '2000-01-01'
If you want rows that are enritely within the target range, it's something else.
If you want rows that entirely enclose the target range, it's something else again. -
Hi,
Please could someone help me on how to write a query to retrieve the data between two dates.
created_date format stored in the database column: 9/18/2007 11:34:03 AM
I tried below but it didn't work
select * from work_table where created_date beween '9/18/2007' and '03/29/2008'
I get 'literal doesn't match format string'
Thanks,date datatype is nls dependent -> folllows the nls_date_format database parameter setting inherited by your session.
Making it short you'll be always safe if you
select * from work_table where created_date beween to_date('9/18/2007','MM/DD/YYYY') and to_date('03/29/2008','MM/DD/YYYY')Having the time component included you must add + 1 - 1 / 24 / 60 / 60 (plus one day minus one second) to the upper limit if you want to include the last day as a whole
*** not tested
Regards
Etbin -
Hi,
I have table like this.
Id in_date value
2 05-Jun-08 5.3
3 08-Jun-08 5.2
4 08-Jun-08 5.3
5 08-Jun-08 5.8
6 10-Jun-08 7
7 10-Jun-08 5.6
8 11-Jun-08 2.6
When I query for average value between two dates, it should return average and if there is no entry for any dates it should return 0 for that date. Here is sample output for dates between 05-Jun-08 and 12-Jun-08.
In_date value
05-Jun-08 5.3
06-Jun-08 0.0
07-Jun-08 0.0
08-Jun-08 5.43
09-Jun-08 0
10-Jun-08 6.3
11-Jun-08 2.6
12-Jun-08 0
Please help me to write query on thisThanks,
SujnanSQL> with t as (
2 select 2 id,to_date('05-Jun-08','dd-mon-rr') in_date,5.3 val from dual union all
3 select 3,to_date('08-Jun-08','dd-mon-rr'),5.2 from dual union all
4 select 4,to_date('08-Jun-08','dd-mon-rr'),5.3 from dual union all
5 select 5,to_date('08-Jun-08','dd-mon-rr'),5.8 from dual union all
6 select 6,to_date('10-Jun-08','dd-mon-rr'),7 from dual union all
7 select 7,to_date('10-Jun-08','dd-mon-rr'),5.6 from dual union all
8 select 8,to_date('11-Jun-08','dd-mon-rr'),2.6 from dual
9 )
10 select t2.in_date,
11 nvl(t1.val,0) + t2.val val
12 from (
13 select in_date,
14 avg(val) val
15 from t
16 group by in_date
17 ) t1,
18 (
19 select min_in_date + level - 1 in_date,
20 0 val
21 from (
22 select min(in_date) min_in_date,
23 max(in_date) max_in_date
24 from t
25 )
26 connect by level <= max_in_date - min_in_date + 1
27 ) t2
28 where t2.in_date = t1.in_date(+)
29 order by t2.in_date
30 /
IN_DATE VAL
05-JUN-08 5.30
06-JUN-08 .00
07-JUN-08 .00
08-JUN-08 5.43
09-JUN-08 .00
10-JUN-08 6.30
11-JUN-08 2.60
7 rows selected.
SQL> SY. -
Query between two tables : COAS and BPGE
Hi,
I want to create a Query between tables : COAS and BPGE but when i generate the Info-set the system had a problem of jointure. (the field OBJNR exist in the both)
By this query i want to display the Order and the value of Budget
Please Advise
Regardshi..
you can go with following type of code....
select coas~field1
coas~field2
bpge~field5
bpeg~field6
from coas inner/outer join bpge
on coasobjnr = bpgeobjnr
into table t_table
where condition
hope this one will solve the issue
regards -
How to calculate the month difference between two date char. in Query?
Customers would like to see how many months passed between two date type of characteristics (e.g., the month difference between the current date and the scheduled delivery date in the record) and put the result into the column as KF.
We would have to grab the fiscal year/period kind of value and then do the subtraction, e.g., if the current date value is 2/28/2008 and the scheduled delivery date value in the record is 12/01/2007, the correct result should be 2 month difference between these two date values, but could someone here give us the technical light on how to make this happen in query design?
Thanks and we will give you reward points for the correct anwsers!Hi Kevin,
The Badi is RSR_OLAP_BADI.
You can create an implementation using Transaction SE18.
The implementation is per cube and is defined in the filters.
In the Implementation you have the following methods :
1. Define : Here you will provide the Keyfigure you need as a virtual one.
2. Initilialize : Any Init Function you want to do.
3. Compute. This is called per datarecord and here you can cimpute your value.
Hope this helps.
Pralay Ahluwalia -
Use of "findByMultipleParameters" for "OR " between two Query Filters
Hi,
I am also working in CE7.1 .I have a query regarding the use of "findByMultipleParameters" .
That is how to use "OR " between two Query Filter condition,because if we add multiple queries into Query Filter List it will by default taking "AND " .
For an example, I have to pull data from a table/BO with a condition col A = 10 OR ( col B > 100 AND col c = "XYZ") .
My code snippet looks like given below.......
List queryFilters = new ArrayList();
QueryFilter queryFilterOne = QueryFilterFactory.createFilter("ROLLUMBER",Condition.EQ, rollNumber);
QueryFilter queryFilterTwo = QueryFilterFactory.createFilter("NAME",Condition.EQ, "123");
queryFilters.add(queryFilterOne);
queryFilters.add(queryFilterTwo);
List students = studentServiceLocal.findByMultipleParameters(queryFilters, false, "xyz");
I have tried all these and found all of them deprecated,Please suggest something appropriate.Your quick response will help a lot.
//queryFilterOne.setAction(QueryFilter.OPERATION_OR);
//QueryFilterFactory.createBoolOperator(queryFilterOne.OPERATION_OR);
//queryFilters.add(QueryFilter.OR);
//queryFilters.add(queryFilterOne.setOperation(QueryFilter.OPERATION_OR));
My another Query is what is the role of implCheck(Boolean),findByName(String) in "findByMultipleParameters()" ?
Thanking you for your help in advance.
Regards,
Sonali
Edited by: Sonali Das on Sep 14, 2010 2:32 PMHi Praveen/Harris,
As Mr Bhanu said , we can get the result by using formula variable defined on attribute with replacement path as processing type.
There is document in https://websmp101.sap-ag.de/bi
in infoindex->How to Calculate with attributes
To findout the difference between formula variable and current date, define one more formula variable with processing as custoemr exit.And fill this variable with sy-datum or something else.
with rgds,
Anil Kumar Sharma .P -
How to switch between two query in Web templete.
Hi all,
Here i am facing problem to switch between two query in web template by using one 'table' web item. is there any way to use hyperlink 'SAP_BW_URL' and we can switch to query. here i am using these HTML code..
<table><tr><td class="SAPBEXBtnStdBorder" cellspacing="0" cellpadding="0" border="0"><tr><td>
<table><tr><td class="sapbexbtnstd" ><A href="<SAP_BW_URL cmd='reset_item' item='table_data' query_ID='ZSD_ZSD_M01_Q20' apply_cmd_on_target= "X">" >Switch to other query</A></td></tr></table>
but i am not getting correct functionality.
please help me to solve this problem.
I know the best way to say thanks in SDN.
thanks
Kiran PatelKiran,
Use the web api reset_data_provider as links or in select option in HTML.
Onchange event of this select option should call JAVASCRIPT method and
this in turn resets the current dataprovider to your concerned one.
How to change graphs:
The graph item has the default data provider:
<object>
<param name="OWNER" value="SAP_BW"/>
<param name="CMD" value="GET_ITEM"/>
<param name="NAME" value="CHART_1"/>
<param name="ITEM_CLASS" value="CL_RSR_WWW_ITEM_CHART"/>
<param name="DATA_PROVIDER" value="DATAPROVIDER_1"/>
<param name="TMP_CHART_DATA_HANDLE" value="IIP_49MOXB0UVNOMM6JOZMZU7QO21"/>
ITEM: CHART_1
</object>
So if you change the DATAPROVIDER_1 using RESET_DATA_PROVIDER to your concerned DP, this changes chart as well !!
Please use this method and refer to sample code for Onchange Event on SELECT OPTION:
<HTML>
<HEAD>
<script>
function callDP() {
if(document.forms[0].dp.value == "1") {
//form your URL here..
url = SAP_BW_URL_Get() + "&CMD=RESET_DATA_PROVIDER&DATA_PROVIDER_1=..&...";
SAPBWOpenURL(url);
//or docuemtn.location.href = url..
//etc..
</script>
</HEAD>
<BODY>
<form>
<select name="dp" onChange="javascript:callDP();">
<option value="1">1</option>
<option value="2">2</option>
</select>
</form>
</BODY>
</HTML>
HOPE THIS HELPS !!! -
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 -
Query for between two dates.
Hi,
I've a column of date, and I want to select the records between two dates, the output of this columns is: 08/19/2003 2:11:00 AM
My query is:
SELECT DTM FROM ITEM
WHERE DTM BETWEEN '07/01/2012' AND '07/15/2012'
Please help.
Thanks,>
I've a column of date, and I want to select the records between two dates, the output of this columns is: 08/19/2003 2:11:00 AM
My query is:
SELECT DTM FROM ITEM
WHERE DTM BETWEEN '07/01/2012' AND '07/15/2012'
Please help.
>
Help with what? You didn't ask a question or indicate if you are having a problem of some sort.
Did you need to know how to use TO_DATE instead of literals in the WHERE clause?
SELECT DTM FROM ITEM
WHERE DTM BETWEEN TO_DATE('07/01/2012', 'MM/DD/YYYY') AND TO_DATE('07/15/2012', 'MM/DD/YYYY'); -
How to query the number of working days between two dates
I'm looking for a solution to calculate the number of <i>working</i> days between two dates that I can use in a formated search.
Calculating the total number of days is pretty straight forward but does anyone know how to take into account the settings in the HLD1 (Holiday Dates) table?Hi Eric,
If you are purely looking to exclude holidays defined in the HLD1 table, then you should be able to do it with the following query
NOTE: The following query is an example using OINV table and the fields DOCDATE and DOCDUEDATE for a Particular DOCNUM 'xxx'
If you planning to use within the SAP module then replace DOCDATE and DOCDUEDATE with dynamic field references $[$x.x.x]
SELECT DATEDIFF(DAY,T0.DOCDATE,T0.DOCDUEDATE)-
(SELECT COUNT(STRDATE) FROM HLD1 WHERE STRDATE >= T0.DOCDATE AND STRDATE <= T0.DOCDUEDATE)
FROM OINV T0
WHERE T0.DOCNUM = xxx
Best Wishes
Suda -
Query to search between two specific dates and time period
Hi,
Need a query to search between two particular dates and time period
Like i want to search table having one date field .
Suppose the date range is '01-JUL-06' and '01-AUG-06' and time frame
is 23:00:00 to 08:00:00
i.e i want to search between dates 01 july to 01 aug and also within the time frame i.e 23:00 to 08:00 hrs onlyThe general principle is
SELECT * FROM your_table
WHERE some_date BEWTEEN to_date('01-JUL-06') and to_date('01-AUG-06' )+0.99999
AND ( some_date <= trunc(some_date)+8/24
OR some_date >= trunc(some_date)+23/24 )
/Cheers, APC -
View Link between two query views
Hi is it possible to create a view link between two views having the where clause bind variables.
How you set the bind variables at the run time for the View objects. It is giving hard time for me to use the Master view in the XmlData bean to generate the Xml document.
I am able to set the Master views bind variables, but for view link destination view
where clause bind variables are not able to set ( link object link condition bind variables are binded run time but the views where chause bind variables of destination view are unable to setand bind)
Thanks
nullEasiest way to do this is to add additional transient attributes to your master view object, and then include those additional transient attributes in the list of source attributes for your view link. This way, you can get BC4J to automatically refer to their values with no additional code on your part.
-
Difference between two date in bex query
Hi all,
I need to do a difference between two date using formula variable processing type customer exit beaucause I must use factory calendar in the formula.
How can I do it?
Can you give me an example of the routine?
Thanks a lot
GianmarcoHi,
You can still use the same code to copy it and customize as per your need. All you need to do is to subract the dates using the class: CL_ABAP_TSTMP after converting to timestamp and resulting seconds you convert back to days....Please get help from the developers to do this...
Also, ensure that you write back this difference value to your variable so you get it on the reports for your calculations...
Cheers,
Emmanuel.
Maybe you are looking for
-
Spell Check in New Forums- How The Heck does it work?
Can somebody please tell me how the spell check works in this new forum format? I click on the abc icon and it does nothing. I do a two finger click on a word that is misspelled and it give me Insert Options. I really like the new format but hate the
-
Photoshop jpeg colors not matching in dreamweaver
inserted a jpeg image created in photoshop cs (8) in dreamweaver and the color is slightly different, a problem because now the image doesn't blend into the background color of the web page. can I setup photoshop to match the color system of dreamwea
-
Hi All, I have a requirement like i have to display some parts of a string in the request. Can any one help me how can i achieve this. Ex: A/P Clerk.FIN.IN.7050.US1000 I have to display IN , for each record the position of IN Segment changes How can
-
Menu Bar Problem with picture.
The right corner of my menu bar has vanished completely including spotlight, the date and time, and various system menu icons. Checking to add these icons in the preferences does not do anything. It is as if the menu bar is "extended" off the screen.
-
How do you change the dpi settings in iPhoto
How do you change the dpi settings in iPhoto