Query help with round up of dates
Hi,
I have a problem with my query.
I am calculating the difference between two dates and I want to get the hours.
The problem is that I want the following to happen:
if the difference is x such that x > 0 it should round it up to 1 (example: x = 0.1 it should be rounded up to 1)
if the difference is y such that y >1 it should be rounded to 1 (example y = 1.05 it should be rounded up to 2)
i have the following query at the momet:
select to_char(arrivaldate,'DD/MM/YYYY hh24:mi:ss') as "ARRIVAL", to_char(departuredate,'DD/MM/YYYY hh24:mi:ss') as "DEPARTURE", round(trunc(mod((departuredate-arrivaldate)*24,24),2)) as duration from stay_log;
thanks.
Hi,
Format your code so that the physical appearance of the code gives some hint as to what you're doing, as I did below.
When posting code on this forum, always type {code} tags at the beginning and end of formatted sections.
Do you mean that, instead of 21, you want to use the flightid from the main query?
If so, that's called a "correllated query". The tables in the main query (and their columns) can be reference in the sub-query, like this:
select flightid as "FLIGHT",
select destairport_id
from journey,
flight
where flight.flightid = stay_log.flight_id -- correlated to main query
and flight.journeyid = journey.journeyid
) AS "AIRPORT",
to_char(arrivaldate,'DD/MM/YYYY hh24:mi:ss') as "ARRIVAL",
to_char(departuredate,'DD/MM/YYYY hh24:mi:ss') as "DEPARTURE",
ceil((departuredate-arrivaldate)*24) as "DURATION",
cost as "COST"
from stay_log;Often, people give a table alias to the main query table that is being referenced in the sub-query, as shown below.
That's only required when the table name appears in both FROM-clauses.
select flightid as "FLIGHT",
select destairport_id
from journey,
flight
where flight.flightid = s.flight_id -- table alias s used here
and flight.journeyid = journey.journeyid
) AS "AIRPORT",
to_char(arrivaldate,'DD/MM/YYYY hh24:mi:ss') as "ARRIVAL",
to_char(departuredate,'DD/MM/YYYY hh24:mi:ss') as "DEPARTURE",
ceil((departuredate-arrivaldate)*24) as "DURATION",
cost as "COST"
from stay_log s -- table alias s defined here
;
Similar Messages
-
Help with writing and retrieving data from a table field with type "LCHR"
Hi Experts,
I need help with writing and reading data from a database table field which has a type of "LCHR". I have given an example of the original code but don't know what to change it to in order to fix it and still read in the original data that's stored in the LCHR field.
Basically we have two Function modules, one that saves list data to a database table and one that reads in this data. Both Function modules have an identicle table which has an array of fields from type INT4, CHAR, and type P. The INT4 field is the first one.
Incidentally this worked in the 4.7 non-unicode system but is now dumping in the new ECC6 Unicode system.
Thanks in advance,
C
SAVING THE LIST DATA TO DB
DATA: L_WA(800).
LOOP AT T_TAB into L_WA.
ZDBTAB-DATALEN = STRLEN( L_WA ).
MOVE: L_WA to ZDBTAB-RAWDATA.
ZDBTAB-LINENUM = SY-TABIX.
INSERT ZDBTAB.
READING THE DATA FROM DB
DATA: BEGIN OF T_DATA,
SEQNR type ZDBTAB-LINENUM,
DATA type ZDBTAB-RAWDATA,
END OF T_TAB.
Select the data.
SELECT linenum rawdata from ZDBTAB into table T_DATA
WHERE repid = w_repname
AND rundate = w_rundate
ORDER BY linenum.
Populate calling Internal Table.
LOOP AT T-DATA.
APPEND T_DATA to T_TAB.
ENDLOOP.Hi Anuj,
The unicode flag is active.
When I run our report and then to try and save the list data a dump is happening at the following point
LOOP AT T_TAB into L_WA.
As I say, T_TAB consists of different fields and field types whereas L_WA is CHAR 800. The dump mentions UC_OBJECTS_NOT_CONVERTIBLE
When I try to load a saved list the dump is happening at the following point
APPEND T_DATA-RAWDATA to T_TAB.
T_DATA-RAWDATA is type LCHR and T_TAB consists of different fields and field types.
In both examples the dumps mention UC_OBJECTS_NOT_CONVERTIBLE
Regards
C -
Hi Gurus,
Can someone please help me out.
I've a below tables.
1) tbl_link --> this table contains information at profile level
2) tbl_summary --> this table contains summary at parent profile level derived from tbl_link table
One parent profile contains multiple child profiles and each child profile links to a code (which is B, W, G or P) and the code is linked to a category (i.e. ONL and OFL). In this case code B is linked to category 'ONL' and codes W,G,P linked to OFL category.
ONL category needs 100 points. If it don't have enough points then i need to borrow from OFL category which i'm doing and populating into tbl_summary table at parent profile level.
Now i need to insert data into tbl_link table at profile level with howmany points used, expired based on tbl_summary table. Rule is at the end of month if we add points for each profile in tbl_link table it should come as 0.
with
tbl_SUMMARY as
select 1 as ppid,'ONL' as catgcode, 53 as earned_points,47 BORROWED_POINTS,100 CERT_POINTS,0 DISCARD_POINTS,100 used from dual
union
select 1 as ppid,'OFL' as catgcode, 223 as earned_points,0 BORROWED_POINTS,176 CERT_POINTS,76 DISCARD_POINTS,100 used from dual
union
select 2 as ppid,'ONL' as catgcode, 39 as earned_points,61 BORROWED_POINTS,100 CERT_POINTS,0 DISCARD_POINTS,100 used from dual
union
select 2 as ppid,'OFL' as catgcode, 90 as earned_points,0 BORROWED_POINTS,29 CERT_POINTS,29 DISCARD_POINTS,100 used from dual
union
select 3 as ppid,'ONL' as catgcode, 109 as earned_points,0 BORROWED_POINTS,109 CERT_POINTS,9 DISCARD_POINTS,100 used from dual
union
select 3 as ppid,'OFL' as catgcode, 223 as earned_points,0 BORROWED_POINTS,223 CERT_POINTS,23 DISCARD_POINTS,200 used from dual
union
select 4 as ppid,'ONL' as catgcode, 109 as earned_points,0 BORROWED_POINTS,109 CERT_POINTS,9 DISCARD_POINTS,100 used from dual
union
select 4 as ppid,'OFL' as catgcode, 169 as earned_points,0 BORROWED_POINTS,169 CERT_POINTS,69 DISCARD_POINTS,100 used from dual
tbl_link as
select 1 as ppid,1 as pid, 'B' as code,'ONL' as catgcode, 53 as earned_points from dual
union
select 1 as ppid,12 as pid, 'W' as code,'OFL' as catgcode, 26 as earned_points from dual
union
select 1 as ppid,13 as pid, 'G' as code,'OFL' as catgcode, 87 as earned_points from dual
union
select 1 as ppid,14 as pid, 'P' as code,'OFL' as catgcode, 110 as earned_points from dual
union
select 2 as ppid,2 as pid, 'B' as code,'ONL' as catgcode, 39 as earned_points from dual
union
select 2 as ppid,22 as pid, 'W' ,'OFL' as catgcode, 30 as earned_points from dual
union
select 2 as ppid,23 as pid, 'G' ,'OFL' as catgcode, 29 as earned_points from dual
union
select 2 as ppid,24 as pid, 'P' ,'OFL' as catgcode, 31 as earned_points from dual
union
select 3 as ppid,3 as pid, 'B' as code,'ONL' as tier_catgcode, 109 as earned_points from dual
union
select 3 as ppid,32 as pid, 'W' ,'OFL' , 26 as earned_points from dual
union
select 3 as ppid,33 as pid, 'G' ,'OFL', 87 as earned_points from dual
union
select 3 as ppid,34 as pid, 'P' ,'OFL' , 110 as earned_points from dual
union
select 4 as ppid,4 as pid, 'B' as code,'ONL' as catgcode, 109 as earned_points from dual
union
select 4 as ppid,42 as pid, 'W' as code,'OFL' , 26 as earned_points from dual
union
select 4 as ppid,43 as pid, 'G' as code,'OFL' , 87 as earned_points from dual
union
select 4 as ppid,44 as pid, 'P' as code,'OFL' , 56 as earned_points from dual
final (PARENT_PROFILE_ID,PROFILE_ID,catgcode,EARNED_POINTS,BORROWED_POINTS,CERT_POINTS,DISCARD_POINTS,USED)
as (
select A.PPID PARENT_PROFILE_ID,B.PID PROFILE_ID,A.catgcode,B.EARNED_POINTS,BORROWED_POINTS,CERT_POINTS,DISCARD_POINTS,USED
from tbl_SUMMARY a,tbl_link b where a.ppid=b.ppid AND A.catgcode=B.catgcode
ORDER BY PROFILE_ID
select * from final order by 1;
PARENT_PROFILE_ID PROFILE_ID CATGCODE EARNED_POINTS BORROWED_POINTS CERT_POINTS DISCARD_POINTS USED
1 1 ONL 53 47 100 0 100
1 14 OFL 110 0 176 76 100
1 13 OFL 87 0 176 76 100
1 12 OFL 26 0 176 76 100
2 2 ONL 39 61 100 0 100
2 24 OFL 31 0 29 29 100
2 23 OFL 29 0 29 29 100
2 22 OFL 30 0 29 29 100
3 32 OFL 26 0 223 23 200
3 33 OFL 87 0 223 23 200
3 34 OFL 110 0 223 23 200
3 3 ONL 109 0 109 9 100
4 42 OFL 26 0 169 69 100
4 43 OFL 87 0 169 69 100
4 44 OFL 56 0 169 69 100
4 4 ONL 109 0 109 9 100
Need Output as below :
For parent profile 1, whatever i mentioned above is not correct. Borrowed 47 points from OFL to ONL to make ONL and also from OFL category has 176 points remaining after lending to ONL and using only 100 points, remaining 76 points are discarded. Need to deduct these 76 points also from child profiles. Output will be as below.
PARENT_PROFILE_ID PROFILE_ID CATGCODE EARNED_POINTS BORROWED_POINTS CERT_POINTS DISCARD_POINTS USED BURN_PTS EXPIRE_PTS
1 1 ONL 53 47 100 0 100 -53 0
1 12 OFL 26 0 176 76 100 -26 0
1 13 OFL 87 0 176 76 100 -74 -13
1 14 OFL 110 0 176 76 100 -47 -63
For parent profile id 2 --> ONL category has 39 points, so borrowed 61 points from OFL category to make ONL points 100.
Now need to populate tbl_link table at child profile level (i.e. child profiles 22,23,24).
Borrowed 61 points from OFL and need to deduct this points from the profile which has highest earned points, in this case deduct from profile 24 which has 31 points, from profile 22 which has 30 points. Need output like below
PARENT_PROFILE_ID PROFILE_ID CATGCODE EARNED_POINTS BORROWED_POINTS CERT_POINTS DISCARD_POINTS USED BURN_PTS EXPIRE_PTS
2 2 ONL 39 61 100 0 100 -39 0
2 22 OFL 30 0 29 29 100 -30 0
2 23 OFL 29 0 29 29 100 0 -29
2 24 OFL 31 0 29 29 100 -31 0
For parent profile id 3 --> ONL category has 109 points, so no need to borrow points from OFL category
Now need to populate tbl_link table at child profile level (i.e. child profiles 32,33,34).
in this case ONL has 100 points, so move the remaining 9 points will be expired. OFL category has 223 points total. need only 200 points (i.e. mutiple of 100) for our process, 23 points will be expired and has to deduct from the profile which has highest earned points, in this case from profile 34. Output :
PARENT_PROFILE_ID PROFILE_ID CATGCODE EARNED_POINTS BORROWED_POINTS CERT_POINTS DISCARD_POINTS USED BURN_PTS EXPIRE_PTS
3 3 ONL 109 0 109 9 100 -100 -9
3 32 OFL 26 0 223 23 200 -26 0
3 33 OFL 87 0 223 23 200 -87 0
3 34 OFL 110 0 223 23 200 -87 -23
For parent profile id 4 --> ONL category has 109 points, so no need to borrow points from OFL category
Now need to populate tbl_link table at child profile level (i.e. child profiles 42,43,44).
in this case ONL has 100 points, so move the remaining 9 points will be expired. OFL category has 169 points total. need only 100 points (i.e. mutiple of 100) for our process, 69 points will be expired and has to deduct from the profile which has highest earned points, in this case from profile 43. Output :
PARENT_PROFILE_ID PROFILE_ID CATGCODE EARNED_POINTS BORROWED_POINTS CERT_POINTS DISCARD_POINTS USED BURN_PTS EXPIRE_PTS
4 4 ONL 109 0 109 9 100 100 9
4 42 OFL 26 0 169 69 100 -26 0
4 43 OFL 87 0 169 69 100 -18 -69
4 44 OFL 56 0 169 69 100 -56 0
Can someone help with the query. I googled about looping in sql and came to know that Oracle has a feature MODEL to loop in SQL, but i don't have idea on using MODEL clause.
Appreciate your help!
Thanks
SriHi Gurus,
Can someone please help me out.
I've a below tables.
1) tbl_link --> this table contains information at profile level
2) tbl_summary --> this table contains summary at parent profile level derived from tbl_link table
One parent profile contains multiple child profiles and each child profile links to a code (which is B, W, G or P) and the code is linked to a category (i.e. ONL and OFL). In this case code B is linked to category 'ONL' and codes W,G,P linked to OFL category.
ONL category needs 100 points. If it don't have enough points then i need to borrow from OFL category which i'm doing and populating into tbl_summary table at parent profile level.
Now i need to insert data into tbl_link table at profile level with howmany points used, expired based on tbl_summary table. Rule is at the end of month if we add points for each profile in tbl_link table it should come as 0.
with
tbl_SUMMARY as
select 1 as ppid,'ONL' as catgcode, 53 as earned_points,47 BORROWED_POINTS,100 CERT_POINTS,0 DISCARD_POINTS,100 used from dual
union
select 1 as ppid,'OFL' as catgcode, 223 as earned_points,0 BORROWED_POINTS,176 CERT_POINTS,76 DISCARD_POINTS,100 used from dual
union
select 2 as ppid,'ONL' as catgcode, 39 as earned_points,61 BORROWED_POINTS,100 CERT_POINTS,0 DISCARD_POINTS,100 used from dual
union
select 2 as ppid,'OFL' as catgcode, 90 as earned_points,0 BORROWED_POINTS,29 CERT_POINTS,29 DISCARD_POINTS,100 used from dual
union
select 3 as ppid,'ONL' as catgcode, 109 as earned_points,0 BORROWED_POINTS,109 CERT_POINTS,9 DISCARD_POINTS,100 used from dual
union
select 3 as ppid,'OFL' as catgcode, 223 as earned_points,0 BORROWED_POINTS,223 CERT_POINTS,23 DISCARD_POINTS,200 used from dual
union
select 4 as ppid,'ONL' as catgcode, 109 as earned_points,0 BORROWED_POINTS,109 CERT_POINTS,9 DISCARD_POINTS,100 used from dual
union
select 4 as ppid,'OFL' as catgcode, 169 as earned_points,0 BORROWED_POINTS,169 CERT_POINTS,69 DISCARD_POINTS,100 used from dual
tbl_link as
select 1 as ppid,1 as pid, 'B' as code,'ONL' as catgcode, 53 as earned_points from dual
union
select 1 as ppid,12 as pid, 'W' as code,'OFL' as catgcode, 26 as earned_points from dual
union
select 1 as ppid,13 as pid, 'G' as code,'OFL' as catgcode, 87 as earned_points from dual
union
select 1 as ppid,14 as pid, 'P' as code,'OFL' as catgcode, 110 as earned_points from dual
union
select 2 as ppid,2 as pid, 'B' as code,'ONL' as catgcode, 39 as earned_points from dual
union
select 2 as ppid,22 as pid, 'W' ,'OFL' as catgcode, 30 as earned_points from dual
union
select 2 as ppid,23 as pid, 'G' ,'OFL' as catgcode, 29 as earned_points from dual
union
select 2 as ppid,24 as pid, 'P' ,'OFL' as catgcode, 31 as earned_points from dual
union
select 3 as ppid,3 as pid, 'B' as code,'ONL' as tier_catgcode, 109 as earned_points from dual
union
select 3 as ppid,32 as pid, 'W' ,'OFL' , 26 as earned_points from dual
union
select 3 as ppid,33 as pid, 'G' ,'OFL', 87 as earned_points from dual
union
select 3 as ppid,34 as pid, 'P' ,'OFL' , 110 as earned_points from dual
union
select 4 as ppid,4 as pid, 'B' as code,'ONL' as catgcode, 109 as earned_points from dual
union
select 4 as ppid,42 as pid, 'W' as code,'OFL' , 26 as earned_points from dual
union
select 4 as ppid,43 as pid, 'G' as code,'OFL' , 87 as earned_points from dual
union
select 4 as ppid,44 as pid, 'P' as code,'OFL' , 56 as earned_points from dual
final (PARENT_PROFILE_ID,PROFILE_ID,catgcode,EARNED_POINTS,BORROWED_POINTS,CERT_POINTS,DISCARD_POINTS,USED)
as (
select A.PPID PARENT_PROFILE_ID,B.PID PROFILE_ID,A.catgcode,B.EARNED_POINTS,BORROWED_POINTS,CERT_POINTS,DISCARD_POINTS,USED
from tbl_SUMMARY a,tbl_link b where a.ppid=b.ppid AND A.catgcode=B.catgcode
ORDER BY PROFILE_ID
select * from final order by 1;
PARENT_PROFILE_ID PROFILE_ID CATGCODE EARNED_POINTS BORROWED_POINTS CERT_POINTS DISCARD_POINTS USED
1 1 ONL 53 47 100 0 100
1 14 OFL 110 0 176 76 100
1 13 OFL 87 0 176 76 100
1 12 OFL 26 0 176 76 100
2 2 ONL 39 61 100 0 100
2 24 OFL 31 0 29 29 100
2 23 OFL 29 0 29 29 100
2 22 OFL 30 0 29 29 100
3 32 OFL 26 0 223 23 200
3 33 OFL 87 0 223 23 200
3 34 OFL 110 0 223 23 200
3 3 ONL 109 0 109 9 100
4 42 OFL 26 0 169 69 100
4 43 OFL 87 0 169 69 100
4 44 OFL 56 0 169 69 100
4 4 ONL 109 0 109 9 100
Need Output as below :
For parent profile 1, whatever i mentioned above is not correct. Borrowed 47 points from OFL to ONL to make ONL and also from OFL category has 176 points remaining after lending to ONL and using only 100 points, remaining 76 points are discarded. Need to deduct these 76 points also from child profiles. Output will be as below.
PARENT_PROFILE_ID PROFILE_ID CATGCODE EARNED_POINTS BORROWED_POINTS CERT_POINTS DISCARD_POINTS USED BURN_PTS EXPIRE_PTS
1 1 ONL 53 47 100 0 100 -53 0
1 12 OFL 26 0 176 76 100 -26 0
1 13 OFL 87 0 176 76 100 -74 -13
1 14 OFL 110 0 176 76 100 -47 -63
For parent profile id 2 --> ONL category has 39 points, so borrowed 61 points from OFL category to make ONL points 100.
Now need to populate tbl_link table at child profile level (i.e. child profiles 22,23,24).
Borrowed 61 points from OFL and need to deduct this points from the profile which has highest earned points, in this case deduct from profile 24 which has 31 points, from profile 22 which has 30 points. Need output like below
PARENT_PROFILE_ID PROFILE_ID CATGCODE EARNED_POINTS BORROWED_POINTS CERT_POINTS DISCARD_POINTS USED BURN_PTS EXPIRE_PTS
2 2 ONL 39 61 100 0 100 -39 0
2 22 OFL 30 0 29 29 100 -30 0
2 23 OFL 29 0 29 29 100 0 -29
2 24 OFL 31 0 29 29 100 -31 0
For parent profile id 3 --> ONL category has 109 points, so no need to borrow points from OFL category
Now need to populate tbl_link table at child profile level (i.e. child profiles 32,33,34).
in this case ONL has 100 points, so move the remaining 9 points will be expired. OFL category has 223 points total. need only 200 points (i.e. mutiple of 100) for our process, 23 points will be expired and has to deduct from the profile which has highest earned points, in this case from profile 34. Output :
PARENT_PROFILE_ID PROFILE_ID CATGCODE EARNED_POINTS BORROWED_POINTS CERT_POINTS DISCARD_POINTS USED BURN_PTS EXPIRE_PTS
3 3 ONL 109 0 109 9 100 -100 -9
3 32 OFL 26 0 223 23 200 -26 0
3 33 OFL 87 0 223 23 200 -87 0
3 34 OFL 110 0 223 23 200 -87 -23
For parent profile id 4 --> ONL category has 109 points, so no need to borrow points from OFL category
Now need to populate tbl_link table at child profile level (i.e. child profiles 42,43,44).
in this case ONL has 100 points, so move the remaining 9 points will be expired. OFL category has 169 points total. need only 100 points (i.e. mutiple of 100) for our process, 69 points will be expired and has to deduct from the profile which has highest earned points, in this case from profile 43. Output :
PARENT_PROFILE_ID PROFILE_ID CATGCODE EARNED_POINTS BORROWED_POINTS CERT_POINTS DISCARD_POINTS USED BURN_PTS EXPIRE_PTS
4 4 ONL 109 0 109 9 100 100 9
4 42 OFL 26 0 169 69 100 -26 0
4 43 OFL 87 0 169 69 100 -18 -69
4 44 OFL 56 0 169 69 100 -56 0
Can someone help with the query. I googled about looping in sql and came to know that Oracle has a feature MODEL to loop in SQL, but i don't have idea on using MODEL clause.
Appreciate your help!
Thanks
Sri -
Query Help with Item Master & Warehouse Code
Forum,
I would like help with a query to identify any items within a database where a particular warehouse code does NOT exist against it. At present I have the following:
select T0.ItemCode, T1.WhsCode from OITM T0
INNER JOIN OITW T1 on T0.ItemCode = T1.ItemCode
where T0.ItemCode NOT IN ('WHS1')
This is returning all other instance and not just a list of item codes where 'WHS1' is missing from within the 'Stock Data' tab.
Thanks,
SarahHi Sarah...
Try This
SELECT T0.ItemCode, T0.ItemName, T1.WhsCode
FROM OITM T0 INNER JOIN OITW T1 ON T0.ItemCode = T1.ItemCode
WHERE T1.WhsCode not in ( 'WHS1')
Regards
Kennedy -
Help with hours between two dates
Hi I need help with the below query
select count(*),a.col1,max(a.dt),min(a.dt)
from tab1 a
where a.dt > to_date('01-JUL-08','dd-mon-yyyy')
group by col1
having count(*) >=2
and (max(a.dt) - min(a.dt))* 24*60*60 > 360;
I am trying to pull the records with more than 2 entries, and having more than 6 hrs difference between max date and min date. When I am trying to execute this I am getting an error at "(max(a.dt) - min(a.dt))* 24*60*60 > 360".
any ideas how can I pull the records more than 6 hrs?
Thanks in advance!Sorry guys...here is the erros i am getting
ORA-00932: inconsistent datatypes: expected INTERVAL DAY TO SECOND got NUMBER
my version : 9.2
SQL>
SQL> @ver
BANNER
Oracle9i Enterprise Edition Release 9.2.0.8.0 - 64bit Production
PL/SQL Release 9.2.0.8.0 - Production
CORE 9.2.0.8.0 Production
TNS for Solaris: Version 9.2.0.8.0 - Production
NLSRTL Version 9.2.0.8.0 - Production
SQL>
SQL>
SQL> --
SQL> drop table tab1;
Table dropped.
SQL> create table tab1 as
2 select 'stin_8723646' as col1, to_date('7/22/2008 5:48:32 AM', 'mm/dd/yyyy hh:mi:ss AM') as dt from dual union all
3 select 'stin_8723646', to_date('7/22/2008 1:34:12 PM', 'mm/dd/yyyy hh:mi:ss AM') from dual union all
4 select 'stin_8723646', to_date('7/22/2008 3:16:25 PM', 'mm/dd/yyyy hh:mi:ss AM') from dual union all
5 select 'stin_8723647', to_date('7/22/2008 1:10:07 AM', 'mm/dd/yyyy hh:mi:ss AM') from dual union all
6 select 'stin_8723647', to_date('7/22/2008 4:19:00 AM', 'mm/dd/yyyy hh:mi:ss AM') from dual union all
7 select 'stin_8723647', to_date('7/22/2008 9:52:44 AM', 'mm/dd/yyyy hh:mi:ss AM') from dual;
Table created.
SQL>
SQL> alter session set nls_date_format = 'mm/dd/yyyy hh:mi:ss am';
Session altered.
SQL>
SQL> select * from tab1;
COL1 DT
stin_8723646 07/22/2008 05:48:32 am
stin_8723646 07/22/2008 01:34:12 pm
stin_8723646 07/22/2008 03:16:25 pm
stin_8723647 07/22/2008 01:10:07 am
stin_8723647 07/22/2008 04:19:00 am
stin_8723647 07/22/2008 09:52:44 am
6 rows selected.
SQL>
SQL> --
SQL> select
2 count(*),
3 a.col1,
4 max(a.dt),
5 min(a.dt)
6 from tab1 a
7 where a.dt > to_date('01-JUL-08','dd-mon-yyyy')
8 group by col1
9 having count(*) >=2
10 --and (max(a.dt) - min(a.dt))* 24*60*60 > 360
11 and (max(a.dt) - min(a.dt))* 24 > 6;
COUNT(*) COL1 MAX(A.DT) MIN(A.DT)
3 stin_8723646 07/22/2008 03:16:25 pm 07/22/2008 05:48:32 am
3 stin_8723647 07/22/2008 09:52:44 am 07/22/2008 01:10:07 am
SQL>
SQL>isotope -
Help with CF Reports and Dates
Can anyone here help me with
This
post ? I have been waiting for 3 days and after 4 posts no one
has been able to answer, please help!! I'm stuck on my project only
because of this. Thank you very, very much.
Nelson.Sorry, I don't use cfreport so I would not be any help with
what may be inside the total_sales_report_by_date.cfr template.
However, shouldn't you be executin your query inside of your .cfm
emplate, then passing the query result to your report as a query
parameter within your cfreport tag, rather than passing the date
parameters in cfreportparam tags?
Phil -
Query Help with Parent, Child, Child's Child
Hi all,
Need some help with a query. I'm trying to create a stored procedure that is sort of like a Customer, Order, Order, Details. In my situation the tables are different but nevertheless, I want to grab all the fields from the Parent, Child,
and Childs' Child, where the Parent.ParentID = @Parameter. I tried this:
CREATE PROCEDURE [dbo].[spGetCompleteProjectXML]
@ProjectID int = 0
AS
SELECT *,
(SELECT *,
(SELECT *
FROM PageControls
WHERE (PageControls.ProjectPageID = ProjectPages.ProjectPageID))
FROM ProjectPages
WHERE (ProjectPages.ProjectID = @ProjectID))
FROM Projects
WHERE (ProjectID = @ProjectID)
FOR XML AUTO, ELEMENTS
RETURN 0
I think I'm close, but it was my best effort. Could someone help?
thanks in advanceHi TPolo,
Regarding your description, are you looking for a sample like below?
CREATE TABLE customer(customerID INT, name VARCHAR(99))
INSERT INTO customer VALUES(1,'Eric')
INSERT INTO customer VALUES(2,'Nelson')
CREATE TABLE orders(orderID INT,customerID INT)
INSERT INTO orders VALUES(1,1);
INSERT INTO orders VALUES(2,1)
INSERT INTO orders VALUES(3,2)
INSERT INTO orders VALUES(4,2)
CREATE TABLE orderDetails(orderID INT,item VARCHAR(99))
INSERT INTO orderDetails VALUES(1,'APPLE1')
INSERT INTO orderDetails VALUES(1,'BANANA1')
INSERT INTO orderDetails VALUES(2,'APPLE2')
INSERT INTO orderDetails VALUES(2,'BANANA2')
INSERT INTO orderDetails VALUES(3,'APPLE3')
INSERT INTO orderDetails VALUES(3,'BANANA3')
INSERT INTO orderDetails VALUES(4,'APPLE4')
INSERT INTO orderDetails VALUES(4,'BANANA5')
SELECT customer.customerID,customer.name,
(SELECT orderId,
SELECT item FROM orderDetails WHERE orderID=orders.orderID FOR XML AUTO,TYPE,ELEMENTS
FROM orders Where customerID=customer.customerID FOR XML AUTO,TYPE,ELEMENTS)
FROM customer WHERE customerID=1
FOR XML AUTO,ELEMENTS
DROP TABLE customer,orderDetails,orders
If you have any feedback on our support, please click
here.
Eric Zhang
TechNet Community Support -
Help with selecting chuncks of data from a table
Hi all,
I need help with a query that should do the following.
I have a table with vessel messages, and I need to get the last "NumMsgs" messages from a group of vessels.
The problem I have is that if I order the table by Vessel_ID, MessageDate DESC, I can´t do ROWNUM < NumMsgs (<-- Then number of messages to be shown is a user parameter)
I know it should be something like:
select * from (
select *
from Messages m
where TRIM(m.V_ID) = '11597' /* I was trying for a single vessel atm */
order by m.V_ID, m.MESSAGEDATE desc
where rownum < :NumMsgs
Any ideas?
Thanks in advance !Hi,
What about :
select *
from (
select m.*, row_number() (order by m.V_ID, m.MESSAGEDATE desc) rn
from Messages m
where TRIM(m.V_ID) = '11597' /* I was trying for a single vessel atm */
where rn < :NumMsgsAnyway, I don't very well understand your problem, your query work fine, see for example :
SQL> ed
Wrote file afiedt.buf
1 select object_name, object_id
2 from
3 (select object_name, object_id, row_number() over (order by object_id desc) as rn
4 from dba_objects)
5* where rn < 4
SQL> /
PS_TL_MTCHD_118 71763
PS_TL_MTCHD_117 71762
PS_TL_MTCHD_116 71761
SQL> ed
Wrote file afiedt.buf
1 select object_name, object_id
2 from
3 (select object_name, object_id
4 from dba_objects
5 order by object_id desc)
6* where rownum < 4
SQL> /
PS_TL_MTCHD_118 71763
PS_TL_MTCHD_117 71762
PS_TL_MTCHD_116 71761
SQL> Nicolas.
Message was edited by:
N. Gasparotto -
Help with Capturing Business Graphics data point
Hi,
I created a BusinessGraphics UI element with SimpleSeries and assigned eventId for the categories and data points. I am able to get the series that is clicked through the event but I would like to know which point (value) is clicked as well.
The steps I followed are
1. Created BG UI element, category and SimpleSeries
2. Assigned eventIDs
3. Created an action class and mapped it to the UI element
4. Code in wdDoModifyView is
if (firstTime)
IWDBusinessGraphics chart = (IWDBusinessGraphics) view.getElement("bgCSB");
chart.mappingOfOnAction().addSourceMapping("id", "pointID");
5. Implemented action class with one parameter (pointID) and able to get the value.
Can someone help me to get the data point values from the user click.
Appreciate your help.
Thanks,
KalyanYou have done everything right, except I don't think you can do this with simple series.
Create something like this:
in the context:
series-> (this node can be with 1..1 cardinality and 1..1 selection)
points->
label (string)
value (int)
pointId (string)
in the business graphics:
create one series (not simple one) and add to it one point of numeric type.
in the properties of business graphics bind seriesSource to series context.
Series: bined poitSource to series.points
Series_points: bind eventId to series.points.pointId
bind label to series.points.label
bind valueSource to series.points
Values (these are the numeric values): bind value to series.points.value
in wdDoModify method do the same thing as you have done already.
Now, when you click on a point you will receive in your event in pointId variable the pointId context attribute value.
Best regards,
Anton -
Help with reloading back up data
I had to restore my bb pearl 8120 the other day. Backed up all data and then had a few problems with it. I have now managed to sort it all but cant reload all my backed up data, I have lost a lot of phone number that I really need.
Any help with this would be fab.
ThanksHello,
Please provide more details, such as:
Specific BB Model (8120)
Specific BB OS level (all 4 octets)
Specific Desktop Software level (also 4 octets)
Carrier
Country
The specific symptoms you witnesses -- "cant reload all my backed up data" doesn't tell us much. Specific details of exactly the steps you attempt and exactly the results you see would be helpful.
Thanks!
Occam's Razor nearly always applies when troubleshooting technology issues!
If anyone has been helpful to you, please show your appreciation by clicking the button inside of their post. Please click here and read, along with the threads to which it links, for helpful information to guide you as you proceed. I always recommend that you treat your BlackBerry like any other computing device, including using a regular backup schedule...click here for an article with instructions.
Join our BBM Channels
BSCF General Channel
PIN: C0001B7B4 Display/Scan Bar Code
Knowledge Base Updates
PIN: C0005A9AA Display/Scan Bar Code -
Help with converting hex to date and time
Hi!
I am using snmp4j libraries to walk the mib tree. The system date is getting returned in 11 hexadecimal octets. I require help in converting it to date and time. I looked up the RFC convention of what each octets represent. Require help with conversion.
Eg: 07:db:06:0a:29:1d:00:2b:05:1e
Thanks,Octets Contents Range
1-2 year 0..65536
3 month 1..12
4 day 1..31
5 hour 0..23
6 minutes 0..59
7 seconds 0..60
(use 60 for leap-second)
8 deci-seconds 0..9
9 direction from UTC '+' / '-'
10 hours from UTC 0..13
11 minutes from UTC 0..59
For example I just took the time an hour ago it came out as
07:db:06:13:12:11:1a:00:2b:05:1e
I have to convert this as a date long value to send it.
Do I have to write an utility of my own to do it? -
Urgent-Need help with code for Master data enhancement
hi Experts,
I have appended YMFRGR field(Table MARC) to 0MAT_PLANT_ATTR datasource.
The key fields in the MARC table are MATNR and WERKS.Can anybody help with the user exit to populate this field,as am pretty new to ABAP.
Thanks in advanceHi,
go through this link which has the similar problem:
https://forums.sdn.sap.com/click.jspa?searchID=1331543&messageID=2794783
hope it helps.
Thanks,
Amith -
Help with form sending the data to email
I have looked all over the Internet for help with this. I have tried numerous video tutorials and for some reason I can't get it to work. I have created a form in flash cs4 AS2. It is a contact information form where the user fills out their information and sends it. I have created a the form in a movie clip (I have also tried it not in a movie clip) with the form components inside that movie clip. I have given each component on the form an instance name.
The form has:
Full name (with instance name=name)
Company (with IN =company)
Title (with IN = title)
Phone (with IN = phone)
Email (with IN = email)
Topic combobox (with IN=topic)
Message box (with IN=msg)
Submit button (with IN=submit)
I need help with the actionscript writing. I am VERY new to flash and have never done any scripting really. Does anyone have a sample file I can look at to see how it works or can someone IM me and I can send my file for them to help me?
My IM is logan3975
Any help is greatly appreciated. I consider myself a pretty technical person so I do learn quick...I just need some guidance until I wrap my head around how this all works. Thanks.Here's a link to a posting elsewhere some had had that may provide some useful info (?)
http://board.flashkit.com/board/showthread.php?t=684031 -
Need help with RANK() on NULL data
Hi All
I am using Oracle 10g and running a query with RANK(), but it is not returning a desired output. Pleas HELP!!
I have a STATUS table that shows the history of order status.. I have a requirement to display the order and the last status date (max). If there is any NULL date for an order then show NULL.
STATUS
ORD_NO | STAT | DT
1 | Open |
1 | Pending |
2 | Open |
2 | Pending |
3 | Open |1/1/2009
3 | Pending |1/6/2009
3 | Close |
4 | Open |3/2/2009
4 | Close |3/4/2009
Result should be (max date for each ORD_NO otherwise NULL):
ORD_NO |DT
1 |
2 |
3 |
4 |3/4/2009
CREATE TABLE Status (ORD_NO NUMBER, STAT VARCHAR2(10), DT DATE);
INSERT INTO Status VALUES(1, 'Open', NULL);
INSERT INTO Status VALUES(1, 'Pending', NULL);
INSERT INTO Status VALUES(2, 'Open', NULL);
INSERT INTO Status VALUES(2, 'Pending',NULL);
INSERT INTO Status VALUES(3, 'Open', '1 JAN 2009');
INSERT INTO Status VALUES(3,'Pending', '6 JAN 2009');
INSERT INTO Status VALUES(3, 'Close', NULL);
INSERT INTO Status VALUES(4, 'Open', '2 MAR 2009');
INSERT INTO Status VALUES(4, 'Close', '4 MAR 2009');
COMMIT;
I tried using RANK function to rank all the orders by date. So used ORDER BY cluse on date in descending order thinking that the null dates would be on top and will be grouped together by each ORD_NO.
SELECT ORD_NO, DT, RANK() OVER (PARTITION BY ORD_NO ORDER BY DT DESC)
FROM Status;
...but the result was something..
ORD_NO |DT |RANKING
*1 | | 1*
*1 | | 1*
*2 | | 1*
*2 | | 1*3 | | 1
3 |1/6/2009 | 2
3 |1/1/2009 | 3
4 |3/4/2009 | 1
4 |3/2/2009 | 2
I am not sure why didn't the first two ORD_NOs didn't group together and why ranking of 1 was assigned to them. I was assuming something like:
ORD_NO |DT |RANKING
*1 | | 1*
*1 | | 2*
*2 | | 1*
*2 | | 1*
3 | | 1
3 |1/6/2009 | 2
3 |1/1/2009 | 3
4 |3/4/2009 | 1
4 |3/2/2009 | 2
Please guide me if I am missing something here?
Regards
SriHi,
If i well understood, you don't need rank
SELECT ord_no, MAX (dt)KEEP (DENSE_RANK LAST ORDER BY dt) dt
FROM status
GROUP BY ord_no
SQL> select * from status;
ORD_NO STAT DT
1 Open
1 Pending
2 Open
2 Pending
3 Open 2009-01-01
3 Pending 2009-01-06
3 Close
4 Open 2009-03-02
4 Close 2009-03-04
9 ligne(s) sélectionnée(s).
SQL> SELECT ord_no, MAX (dt)KEEP (DENSE_RANK LAST ORDER BY dt) dt
2 FROM status
3 GROUP BY ord_no;
ORD_NO DT
1
2
3
4 2009-03-04
SQL> -
Help with copying SP List data to SQL Server
I need to read some data from a SP list and copy it to a table in SQL Server.
Visual Studio BIDS 2013. SharePoint 2010. Planning to migrate to 2013 this year. I tried to use the
SP Data source/destination adapter with SSIS, but learned that I can't with Visual Studio 2013. I'm really looking for any way to read data from a SP list and import it into a SQL database (SQL 2014). Haven't found anything online that has worked for me the
way they say it should (such as OData connection in SSIS). Maybe it's version issues.
Does anyone have a solid step-by step to do this? I am not a C# developer...Hi,
According to your description, my understanding is that you want to read SharePoint list data and copy it to SQL Server table.
Hatim's option is a way to achieve it manually.
If you want to do it automatically, I suggest you can create a console application to read SharePoint list using CAML Query and Client Object Model, Then use SqlConnection object to connect database, then you can insert record using SqlCommand object.
Here are some detailed code demos for your reference:
http://www.codeproject.com/Articles/399156/SharePoint-Client-Object-Model-Introduction
https://msdn.microsoft.com/en-us/library/ms233812.aspx
Thanks
Best Regards
Forum Support
Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
[email protected]
Jerry Guo
TechNet Community Support
Maybe you are looking for
-
The product key on the back of my Dell Laptop (SN: 6PSVPR1) is not easy to read. How can I get it?
-
OS X 10.6.3 Why no software updates found?
Hi, I recently installed Snow Leopard 10.6.3 on my 2009 aluminium Macbook using a DVD. The installation went fine. I then went to Software Update so that I could update the system to 10.6.8. It said there were numerous updates to install but, for som
-
Security advice on mandatory access control
Hi, i'm trying to optimize my arch setup and also want to improve my security so i came across the MAC-stuff and would like to hear your oppinion. My usercase is normal browsing/coding/multimedia stuff so nothing so special. I try to maintain my syst
-
Adobe X will not print (pdf) from within Elements 7. It did in my old XP machine. I just switched to a W7 machine and it prints a blank page from any .extension. It does work from within Adobe X but I have to save the Elements file then go get it wi
-
Schedule time to shut down cisco IP phones
Dear All, i would like to ask if there is any way to schedule time on CUCM 7 allowing us to shut down cisco ip phones during week ends, and which cisco ip phone models that support this feature. regards