First() and last() aggergate cql query error
Hi all,
I am getting this below error for this query:
Istream(select
T.firstc as DSTINT,
T.lastc as ASINT,
T.avgCc1 as ASFLT,
T.Ac1 as ASDBL
from
mdsmsInp
MATCH_RECOGNIZE (
MEASURES
first(C.INT1) as firstc,
last(C.INT1) as lastc,
avg(C.FLOAT1) as avgCc1,
A.DOUBLE1 as Ac1
PATTERN(A B C* D)
DEFINE
A as A.INT1 = 9,
B as B.FLOAT1 = 255.281,
C as C.DOUBLE1 = 343.281,
D as D.INT1 = 23
) as T
error traces:
<Aug 24, 2011 6:27:52 PM IST> <Emergency> <CQLServer> <BEA-000000> <alter query Query7 start>
<Aug 24, 2011 6:27:52 PM IST> <Emergency> <CQLServer> <BEA-000000> <alter query Query7 start
java.lang.NullPointerException>
<Aug 24, 2011 6:27:52 PM IST> <Emergency> <CQLServerTrace> <BEA-000000> <java.lang.NullPointerException>
<Aug 24, 2011 6:27:52 PM IST> <Error> <CQLProcessor> <BEA-000000> <CQLProcessor internal error for DDL [alter query Query7 start] = null
java.sql.SQLException
at oracle.cep.jdbc.CEPStatement.evaluateAndSend(CEPStatement.java:323)
at oracle.cep.jdbc.CEPStatement.executeUpdate(CEPStatement.java:302)
at com.oracle.cep.processor.cql.impl.CEPServerInstance.executeDDL(CEPServerInstance.java:257)
at com.oracle.cep.processor.cql.impl.CQLProcessorImpl.executeDDL(CQLProcessorImpl.java:1883)
at com.oracle.cep.processor.cql.impl.CQLQuery.start(CQLQuery.java:46)
at com.oracle.cep.processor.cql.impl.CQLProcessorImpl.activateRules(CQLProcessorImpl.java:677)
at com.oracle.cep.processor.cql.impl.CQLProcessorImpl.activate(CQLProcessorImpl.java:733)
at com.oracle.cep.processor.cql.impl.CQLProcessorImpl.afterConfigurationActive(CQLProcessorImpl.java:1420)
at com.bea.wlevs.spring.ActivationBeanPostProcessor.postProcessAfterContextInitialization(ActivationBeanPostProcessor.java:20)
at com.bea.wlevs.spring.DeferredBeanPostProcessor.afterConfigurationActive(DeferredBeanPostProcessor.java:27)
at com.bea.wlevs.spring.ApplicationContextLifecycle.onApplicationEvent(ApplicationContextLifecycle.java:112)
at org.springframework.context.event.SimpleApplicationEventMulticaster$1.run(SimpleApplicationEventMulticaster.java:78)
at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:49)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:76)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:274)
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:736)
at org.springframework.osgi.context.support.AbstractOsgiBundleApplicationContext.finishRefresh(AbstractOsgiBundleApplicationContext.java:235)
at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:358)
at org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)
at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:320)
at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:136)
at org.springframework.scheduling.commonj.DelegatingWork.run(DelegatingWork.java:61)
at weblogic.work.commonj.CommonjWorkManagerImpl$WorkWithListener.run(CommonjWorkManagerImpl.java:196)
at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:528)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
Caused By: java.lang.NullPointerException
at oracle.cep.planmgr.codegen.StreamSourceFactory.setupExecOpt(StreamSourceFactory.java:191)
at oracle.cep.planmgr.codegen.ExecOptFactory.instantiate(ExecOptFactory.java:198)
at oracle.cep.planmgr.codegen.OptInst.instOp(OptInst.java:129)
at oracle.cep.planmgr.codegen.CodeGenHelper.instantiate(CodeGenHelper.java:91)
at oracle.cep.planmgr.PlanManager.instantiate(PlanManager.java:1062)
at oracle.cep.metadata.QueryManager.instantiate(QueryManager.java:835)
at oracle.cep.metadata.QueryManager.startQuery(QueryManager.java:474)
at oracle.cep.metadata.QueryManager.startNamedQuery(QueryManager.java:266)
at oracle.cep.server.CommandDriver.QueryRefNodeDriver.execute(QueryRefNodeDriver.java:54)
at oracle.cep.server.CommandInterpreter.execute(CommandInterpreter.java:264)
at oracle.cep.server.CEPServer.executeDDL(CEPServer.java:182)
at oracle.cep.jdbc.CEPStatement.evaluateAndSend(CEPStatement.java:320)
at oracle.cep.jdbc.CEPStatement.executeUpdate(CEPStatement.java:302)
at com.oracle.cep.processor.cql.impl.CEPServerInstance.executeDDL(CEPServerInstance.java:257)
at com.oracle.cep.processor.cql.impl.CQLProcessorImpl.executeDDL(CQLProcessorImpl.java:1883)
at com.oracle.cep.processor.cql.impl.CQLQuery.start(CQLQuery.java:46)
at com.oracle.cep.processor.cql.impl.CQLProcessorImpl.activateRules(CQLProcessorImpl.java:677)
at com.oracle.cep.processor.cql.impl.CQLProcessorImpl.activate(CQLProcessorImpl.java:733)
at com.oracle.cep.processor.cql.impl.CQLProcessorImpl.afterConfigurationActive(CQLProcessorImpl.java:1420)
at com.bea.wlevs.spring.ActivationBeanPostProcessor.postProcessAfterContextInitialization(ActivationBeanPostProcessor.java:20)
at com.bea.wlevs.spring.DeferredBeanPostProcessor.afterConfigurationActive(DeferredBeanPostProcessor.java:27)
at com.bea.wlevs.spring.ApplicationContextLifecycle.onApplicationEvent(ApplicationContextLifecycle.java:112)
at org.springframework.context.event.SimpleApplicationEventMulticaster$1.run(SimpleApplicationEventMulticaster.java:78)
at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:49)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:76)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:274)
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:736)
at org.springframework.osgi.context.support.AbstractOsgiBundleApplicationContext.finishRefresh(AbstractOsgiBundleApplicationContext.java:235)
at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:358)
at org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)
at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:320)
at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:136)
at org.springframework.scheduling.commonj.DelegatingWork.run(DelegatingWork.java:61)
at weblogic.work.commonj.CommonjWorkManagerImpl$WorkWithListener.run(CommonjWorkManagerImpl.java:196)
at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:528)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
>
Please guide me on this..
Advance thanks.
Hi thanks for your time.
i tried by removing ISTREAM as shown below but still same error i am facing.
select
T.firstc as DSTINT,
T.lastc as ASINT,
T.avgCc1 as ASFLT,
T.Ac1 as ASDBL,
T.Bc1 as ASBYT,
T.Dc1 as ASCHR
from
mdsmsInp
MATCH_RECOGNIZE (
MEASURES
first(C.INT1) as firstc,
last(C.INT1) as lastc,
avg(C.FLOAT1) as avgCc1,
A.DOUBLE1 as Ac1,
B.BYTE1 as Bc1,
D.CHAR1 as Dc1
PATTERN(A B C* D)
DEFINE
A as A.INT1 = 9,
B as B.FLOAT1 = 255.281,
C as C.DOUBLE1 = 343.281,
D as D.INT1 = 23
) as T
Similar Messages
-
Query : first and last 25 records of a table
Hi @ll,
i am going to write a query for a report. Therefor i need the first and last 25 records of a table. Does anyone got an idea for a solution ? I was trying to achieve this by using a WHERE clause. Here is a part of the query :
SELECT
TOP 10 T1.[ItemCode], DATEPART(mm, T1.[DocDate]) [.....]
FROM FROM INV1 T1
Where T1.[DocDate] >= Cast('2009 [......] AND
T1.ItemCode = (
SELECT TOP 10 T40.[ItemCode]
FROM DBO.OINM
WHERE Where T40.[DocDate] >= Cast('2009-04-01 00:00:00' AS datetime)
AND T40.[DocDate] <= Cast('2009-04-30 00:00:00' AS datetime)
GROUP BY T1.[ItemCode], DATEPART(mm, T40.[DocDate])
ORDER BY SUM(T1.[TotalSumSy]) ASC)
The where part i would use twice, once for ascending the other one for descending. But it does not work.
Any ideas ?
Regards SteffenHi,
Union was the keyword, that i was searching for. It is a nice way, but not practible.
We are using coresuite for generating reports, and there were a nice possibility to connect diffrent queries.
Thanks for your suggestion.
Regards Steffen -
Format first and last record of result query
Hello
I have the following query
<tt>select 1 seq, 'This is First record' data from dual union all
select 2, 'Data ' || tname from tab union all
select 3, 'This was last record Last record' from dual
order by 1</tt>
When i spool this statement to a listfile with col seq noprint option i get:
This is First record
Data MLA_ACCESS_LIST
Data MLA_APPLICATIONS
Data MLA_VPD_PCK
Data MLA_VPD_TABLES
This was last record Last record
But i want:
This is First record MLA_ACCESS_LIST
Data MLA_APPLICATIONS
Data MLA_VPD_PCK
MLA_VPD_TABLES This was last record Last record
I tried it with 1 statement with usage of lead and lag, because first and last record have to differ from the other result records. But i get ORA-30484: missing window specification for this function
Is this possible with 1 statement or am i doomed to edit the results by myself?
Thanks Aukeselect case row_number() over (order by tname)
when 1 then 'This is the First record '
end || tname ||
case row_number() over (order by tname desc)
when 1 then ' This was the last record'
end
from tab
order by tname
hth -
Query to find first and last call made by selected number for date range
Hi,
query to find first and last call made by selected number for date range
according to filter:
mobile_no : 989.....
call_date_from : 25-april-2013
call_date_to : 26-april-2013
Please helpHi,
It sounds like you want a Top-N Query , something like this:
WITH got_nums AS
SELECT table_x.* -- or list columns wanted
, ROW_NUMBER () OVER (ORDER BY call_date ) AS a_num
, ROW_NUMBER () OVER (ORDER BY call_date DESC) AS d_num
FROM table_x
WHERE mobile_no = 989
AND call_date >= DATE '2013-04-25'
AND call_date < DATE '2013-04-26' + 1
SELECT * -- or list all columns except a_num and d_num
FROM got_nums
WHERE 1 IN (a_num, d_num)
;This forum is devoted to the SQL*Plus and iSQL*Plus front ends. This question doesn't have anything to do with any front end, does it? In the future, you'll get better response if you post questions like this in the PL/SQL.
I hope this answers your question.
If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only), and also post the results you want from that data.
Explain, using specific examples, how you get those results from that data.
Always say which version of Oracle you're using (e.g., 11.2.0.2.0).
See the SQL forum FAQ {message:id=9360002} -
Finding first and last members of a group set
Is there any example how to use 'first' and 'last' functions in an sql query ?
I have tried to execute a query like this on the scott.emp table :
select deptno,min(sal),max(sal),first(sal) from emp group by deptno;
but I always get this message:
ERROR at line 1:
ORA-00904: "FIRST": invalid identifier
btw I use Oracle RDBMS ver 9.1.0.3 for Solaris in my server.
tx for your help
sjarifSyarif,
The FIRST and LAST functions, which became available with 9i, are used to find the first or last member of a ranked set. I'm not sure exactly what you are trying to do, but I can show you a query that should work (I don't have 9i handy at the moment). This query should give you the departments with the highest (first) and lowest (last) aggregate salaries:
select deptno,
min(deptno)
keep (dense_rank first order by sum(sal) desc) highest_sal,
min(deptno)
keep (dense_rank last order by sum(sal) desc) lowest_sal
from emp
group by deptno
Is there any example how to use 'first' and 'last' functions in an sql query ?
I have tried to execute a query like this on the scott.emp table :
select deptno,min(sal),max(sal),first(sal) from emp group by deptno;
but I always get this message:
ERROR at line 1:
ORA-00904: "FIRST": invalid identifier
btw I use Oracle RDBMS ver 9.1.0.3 for Solaris in my server.
tx for your help
sjarif -
Select first and last records in grouped results - Oracle 11g
Say I have the following information in an Oracle 11g table:
Qty
Production order
Date and time
20
00000000000000001
12-JAN-14 00:02
20
00000000000000001
12-JAN-14 00:05
20
00000000000000001
12-JAN-14 00:07
20
00000000000000001
13-JAN-14 00:09
30
00000000000000002
12-JAN-14 00:11
30
00000000000000002
12-JAN-14 00:15
30
00000000000000002
12-JAN-14 00:20
30
00000000000000002
14-JAN-14 00:29
I would like to write a query that would return the following:
Qty
Production order
First
Last
80
00000000000000001
12-JAN-14 00:02
13-JAN-14 00:09
120
00000000000000002
12-JAN-14 00:11
14-JAN-14 00:29
That is, the sum of the Qty column grouped by Production order, and the date/time of the first and last records for each Production order.
I came up with a query that yielded this result:
Qty
Production order
First
Last
80
00000000000000001
12-JAN-14 00:02
14-JAN-14 00:29
120
00000000000000002
12-JAN-14 00:02
14-JAN-14 00:29
Which means that the First and Last columns show the overall first and last date / time of the whole table. Please note that this is a dummy table. Sorry I am now allowed to write the actual query
I came up with since work policies do not allow me to share it. Also, I tried with windowing functions such as rank()and row_number() but my user does not have enough privileges to do so.
Any help or hints will be greatly appreciated.Due to the fact that Oracle does not record the rows in any particular order, it would be wrong that the "first date" would be the first row processed by the query.
Therefore you would have to supply some other column if you do not want to consider the table as ordered by date.
Also, any analytical functions will need you to supply the "order by" and if its the date, then just a simple query will do:
SQL>WITH Tab1 (Qty, Production_Order, Pdate)
2 AS (SELECT 20, '00000000000000001', TO_DATE ( '12-JAN-14 00:02', 'DD-MON-YY HH24:MI') FROM DUAL UNION ALL
3 SELECT 20, '00000000000000001', TO_DATE ( '12-JAN-14 00:05', 'DD-MON-YY HH24:MI') FROM DUAL UNION ALL
4 SELECT 20, '00000000000000001', TO_DATE ( '12-JAN-14 00:07', 'DD-MON-YY HH24:MI') FROM DUAL UNION ALL
5 SELECT 20, '00000000000000001', TO_DATE ( '13-JAN-14 00:09', 'DD-MON-YY HH24:MI') FROM DUAL UNION ALL
6 SELECT 30, '00000000000000002', TO_DATE ( '12-JAN-14 00:11', 'DD-MON-YY HH24:MI') FROM DUAL UNION ALL
7 SELECT 30, '00000000000000002', TO_DATE ( '12-JAN-14 00:15', 'DD-MON-YY HH24:MI') FROM DUAL UNION ALL
8 SELECT 30, '00000000000000002', TO_DATE ( '12-JAN-14 00:20', 'DD-MON-YY HH24:MI') FROM DUAL UNION ALL
9 SELECT 30, '00000000000000002', TO_DATE ( '14-JAN-14 00:29', 'DD-MON-YY HH24:MI') FROM DUAL)
10 SELECT SUM ( Qty), Production_Order, MIN ( Pdate), MAX ( Pdate)
11 FROM Tab1
12 GROUP BY Production_Order
13* ORDER BY Production_Order
SQL> /
SUM(QTY) PRODUCTION_ORDER MIN(PDATE) MAX(PDATE)
80 00000000000000001 12-Jan-2014 00:02:00 13-Jan-2014 00:09:00
120 00000000000000002 12-Jan-2014 00:11:00 14-Jan-2014 00:29:00 -
Get first and last day given month name with combobox
hi guys ;
I loaded to month name in combobox and I want to get first and last day by the name of month from selected Combobox
So if I select to february than results get 01.02.2015 and 28.02.2015
if select March than 01.03.2015 and 31.03.2015
Thanks .Thank you for useful post , How to change Culturinfo as a Turkish Month name ?
your's code is work if I use English month name But it was get error when use the turkish month name
If you are running your application on a Turkish Windows you could use the System.Globalization.CultureInfo.CurrentCulture:
int month = DateTime.ParseExact(monthName, "MMMM", System.Globalization.CultureInfo.CurrentCulture).Month;
Or you could use create an explicit culture object like this:
System.Globalization.CultureInfo ci = new System.Globalization.CultureInfo("tr-TR");
int month = DateTime.ParseExact(monthName, "MMMM", ci).Month;
Please remember to mark all helpful posts as answer to close your threads. -
ORA-01847: day of month must be between 1 and last day of month error
Hi All
When i run the following code i'm getting the error:ORA-01847: day of month must be between 1 and last day of month error
SELECT t2.owner_cat,
t1.owner_id,
stock_id,
Sum(received_amount) received_amount,
Sum(curr_amount) curr_amount,
Sum(used_amount) used_amount,
To_char(Add_months(date_work,6),'YYYY') date_work
FROM (SELECT owner_id_to owner_id,
stock_id_to stock_id,
Sum(full_amount) received_amount,
0 curr_amount,
0 used_amount,
To_char(0) date_work
FROM dw_wms_mat_transfer
WHERE master_code_id IN ('8664','8665')
GROUP BY owner_id_to,
stock_id_to
UNION ALL
SELECT owner_id,
stock_id,
0 received_amount,
Sum(curr_amount) curr_amount,
0 used_amount,
To_char(0) date_work
FROM dw_wms_mat_inv
WHERE master_code_id IN ('8664','8665')
GROUP BY owner_id,
stock_id
UNION ALL
SELECT t2.owner_id,
t1.stock_id,
0 received_amt,
0 curr_amt,
Sum(amount) used_amt,
To_char(Add_months(date_work,6),'YYYY') date_work
FROM dw_wms_wo_mat_dc t1,
(SELECT owner_id,
stock_id
FROM dw_wms_mat_inv
WHERE master_code_id IN ('8664','8665')
GROUP BY owner_id,
stock_id) t2
WHERE t1.stock_id = t2.stock_id
GROUP BY t2.owner_id,
t1.stock_id,
To_char(Add_months(date_work,6),'YYYY')) t1,
dw_wms_setup_owner t2
WHERE t1.owner_id = t2.owner_id
GROUP BY t2.owner_cat,
t1.owner_id,
stock_id,
To_char(Add_months(date_work,6),'YYYY')
But when i just run the inner query:
(SELECT owner_id_to owner_id,
stock_id_to stock_id,
Sum(full_amount) received_amount,
0 curr_amount,
0 used_amount,
To_char(0) date_work
FROM dw_wms_mat_transfer
WHERE master_code_id IN ('8664','8665')
GROUP BY owner_id_to,
stock_id_to
UNION ALL
SELECT owner_id,
stock_id,
0 received_amount,
Sum(curr_amount) curr_amount,
0 used_amount,
To_char(0) date_work
FROM dw_wms_mat_inv
WHERE master_code_id IN ('8664','8665')
GROUP BY owner_id,
stock_id
UNION ALL
SELECT t2.owner_id,
t1.stock_id,
0 received_amt,
0 curr_amt,
Sum(amount) used_amt,
To_char(Add_months(date_work,6),'YYYY') date_work
FROM dw_wms_wo_mat_dc t1,
(SELECT owner_id,
stock_id
FROM dw_wms_mat_inv
WHERE master_code_id IN ('8664','8665')
GROUP BY owner_id,
stock_id) t2
WHERE t1.stock_id = t2.stock_id
GROUP BY t2.owner_id,
t1.stock_id,
To_char(Add_months(date_work,6),'YYYY'))
I'm not getting that error, any help please?Hi,
Like Anuraq already explained, you need to keep in mind that when you apply a to_char, you've turned your DATE datatype into a STRING and by doing that you've lost the ability to use the add_months function again in your outer query.
Using a simplified example, extracted from your example:
MHO%xe> select to_char(add_months(date_work, 6), 'yyyy') date_work
2 from ( select to_char(0) date_work
3 from dual
4 union all
5 select to_char(0) date_work
6 from dual
7 union all
8 select to_char(add_months(sysdate, 6), 'yyyy') date_work
9 from dual
10 );
select to_char(add_months(date_work, 6), 'yyyy') date_work
FOUT in regel 1:
.ORA-01847: day of month must be between 1 and last day of monthHowever, you should either do something like:
MHO%xe> select nvl(to_char(add_months(date_work, 12), 'yyyy'), '0') date_work
2 from ( select to_date(null) date_work
3 from dual
4 union all
5 select to_date(null) date_work
6 from dual
7 union all
8 select sysdate date_work
9 from dual
10 );
DATE
0
0
2010or (less clear, more confusing):
MHO%xe> select nvl(to_char(add_months(date_work, 6), 'yyyy'), '0') date_work
2 from ( select to_date(null) date_work
3 from dual
4 union all
5 select to_date(null) date_work
6 from dual
7 union all
8 select add_months(sysdate, 6) date_work
9 from dual
10 );
DATE
0
0
2010It's not clear to me why you're using add_months twice (inner + outer query) in your original example.
As you can see you can get the same results using it only once in your outer query. -
I need to build a linear list of the string positions of the
first and last character of each word in a string. For example if I
have the string myPet = “DOG CAT FISH” then myList =
[[1,3],[5,7],[9,12]]
myPet.word[x] will let me access the individual words but
I’m not sure how to get the char position of the beginning
and end of each. Please help, it’s Friday and my brain has
left for the weekend.Touche, Sean.
"Sean Wilson" <[email protected]> wrote in
message
news:fqa8ap$bga$[email protected]..
> Hi Craig,
>
> Your's fails if any word is repeated. Try it with "DOG
CAT FISH DOG"
>
> This one seems to work, although there are probably more
efficient ways to
> go about it. A regular expression and the PRegEx xtra
would certainly be
> quicker, especially as the string gets longer
>
> on mGetWordBoundaries aString
> -- basic error check
> if stringP(aString) = 0 then return []
> if length(aString) = 0 then return []
>
> lWhitespace = [SPACE, TAB, RETURN, numToChar(10)]
> tStart = 1
> tChar = aString.char[tStart]
> repeat while lWhitespace.getPos(tChar)
> tStart = tStart + 1
> tChar = aString.char[tStart]
> end repeat
>
> lPositions = []
> repeat with w = 1 to aString.word.count
> tEnd = tStart + aString.word[w].char.count - 1
> lPositions.append([tStart, tEnd])
> tStart = tEnd + 1
> tChar = aString.char[tStart]
> repeat while lWhitespace.getPos(tChar)
> tStart = tStart + 1
> tChar = aString.char[tStart]
> end repeat
> end repeat
> return lPositions
> end -
How to split 'Firstname Lastname' into 2 columns 'First' and 'Last'?
I import a .csv file from PayPal that throws the customer's First name, MI and Last Name all in one column. I have no problem going through and deleting the middle initial to make just two words separated with a space.
How can I split the First and Last names that are separated by a space into two separate columns? It's a piece of cake in Excel, but for some stupid reason, I can't use Excel 08 for Mac to do it. Keeps saying that there is data in column #XX without a heading (there is no data there) when I try to import to PayPal Multi-order shipping.
Please help! I'm desperate. Taking me for ever to cut and past each last name into the new column.
Thanks for any help with this!
MarcusHere is a script which does the trick.
--[SCRIPT splitfirst_lastname]
Enregistrer le script en tant que Script ou Application : splitfirst_lastname.xxx
déplacer le fichier ainsi créé dans le dossier
<VolumeDeDémarrage>:Users:<votreCompte>:Library:Scripts:Applications:Numbers:
Il vous faudra peut-être créer le dossier Numbers et peut-être même le dossier Applications.
Sélectionner la colonne de chaînes à découper (et éventuellement davantage pour définir la colonne recevant les noms propres).
Aller au menu Scripts , choisir Numbers puis choisir splitfirst_lastname
Le script découpe les chaînes sources au premier espace.
Le prénom remplace la chaîne initiale.
Le reste est déposé dans la cellule adjacente à droite ou dans la cellule de la denière colonne sélectionnée.
--=====
L'aide du Finder explique:
L'Utilitaire AppleScript permet d'activer le Menu des scripts :
Ouvrez l'Utilitaire AppleScript situé dans le dossier Applications/AppleScript.
Cochez la case "Afficher le menu des scripts dans la barre de menus".
Sous 10.6.x,
aller dans le panneau "Général" du dialogue Préférences de l'Éditeur Applescript
puis cocher la case "Afficher le menu des scripts dans la barre des menus".
--=====
Save the script as a Script or an Application : splitfirst_lastname.xxx
Move the newly created file into the folder:
<startup Volume>:Users:<yourAccount>:Library:Scripts:Applications:Numbers:
Maybe you would have to create the folder Numbers and even the folder Applications by yourself.
Select a column of strings to split (and maybe more columns to define the column receiving lastNames).
Go to the Scripts Menu, choose Numbers, then choose "splitfirst_lastname"
The script split the source strings on the first embedded space.
The FirstName replace the original string.
The reminder is stored in the cell adjacent on the right (or in the last column of the selected range.
--=====
The Finder's Help explains:
To make the Script menu appear:
Open the AppleScript utility located in Applications/AppleScript.
Select the "Show Script Menu in menu bar" checkbox.
Under 10.6.x,
go to the General panel of AppleScript Editor’s Preferences dialog box
and check the “Show Script menu in menu bar” option.
--=====
Yvan KOENIG (VALLAURIS, France)
2011/02/23
--=====
on run
run script doyourduty
end run
--=====
script doyourduty
set {dName, sName, tName, rname, rowNum1, colNum1, rowNum2, colNum2} to my getSelParams()
if colNum2 = colNum1 then set colNum2 to colNum1 + 1
tell application "Numbers" to tell document dName to tell sheet sName to tell table tName
repeat with r from rowNum1 to rowNum2
tell row r
set first_last to value of cell colNum1
if (first_last is not 0.0) and first_last contains space then
set in_pieces to my decoupe(first_last, space)
set value of cell colNum1 to item 1 of in_pieces
set value of cell colNum2 to my recolle(items 2 thru -1 of in_pieces, space)
end if
end tell -- row
end repeat
end tell -- Numbers
end script
--=====
set {rowNum1, colNum1, rowNum2, colNum2} to my getCellsAddresses(dname,s_name,t_name,arange)
on getCellsAddresses(d_Name, s_Name, t_Name, r_Name)
local two_Names, row_Num1, col_Num1, row_Num2, col_Num2
tell application "Numbers"
set d_Name to name of document d_Name (* useful if we passed a number *)
tell document d_Name
set s_Name to name of sheet s_Name (* useful if we passed a number *)
tell sheet s_Name
set t_Name to name of table t_Name (* useful if we passed a number *)
end tell -- sheet
end tell -- document
end tell -- Numbers
if r_Name contains ":" then
set two_Names to my decoupe(r_Name, ":")
set {row_Num1, col_Num1} to my decipher(d_Name, s_Name, t_Name, item 1 of two_Names)
if item 2 of two_Names = item 1 of two_Names then
set {row_Num2, col_Num2} to {row_Num1, col_Num1}
else
set {row_Num2, col_Num2} to my decipher(d_Name, s_Name, t_Name, item 2 of two_Names)
end if
else
set {row_Num1, col_Num1} to my decipher(d_Name, s_Name, t_Name, r_Name)
set {row_Num2, col_Num2} to {row_Num1, col_Num1}
end if -- r_Name contains…
return {row_Num1, col_Num1, row_Num2, col_Num2}
end getCellsAddresses
--=====
set { dName, sName, tName, rname, rowNum1, colNum1, rowNum2, colNum2} to my getSelParams()
on getSelParams()
local r_Name, t_Name, s_Name, d_Name
set {d_Name, s_Name, t_Name, r_Name} to my getSelection()
if r_Name is missing value then
if my parleAnglais() then
error "No selected cells"
else
error "Il n'y a pas de cellule sélectionnée !"
end if
end if
return {d_Name, s_Name, t_Name, r_Name} & my getCellsAddresses(d_Name, s_Name, t_Name, r_Name)
end getSelParams
--=====
set {rowNumber, columnNumber} to my decipher(docName,sheetName,tableName,cellRef)
apply to named row or named column !
on decipher(d, s, t, n)
tell application "Numbers" to tell document d to tell sheet s to tell table t to ¬
return {address of row of cell n, address of column of cell n}
end decipher
--=====
set { d_Name, s_Name, t_Name, r_Name} to my getSelection()
on getSelection()
local _, theRange, theTable, theSheet, theDoc, errMsg, errNum
tell application "Numbers" to tell document 1
repeat with i from 1 to the count of sheets
tell sheet i
set x to the count of tables
if x > 0 then
repeat with y from 1 to x
try
(selection range of table y) as text
on error errMsg number errNum
set {_, theRange, _, theTable, _, theSheet, _, theDoc} to my decoupe(errMsg, quote)
return {theDoc, theSheet, theTable, theRange}
end try
end repeat -- y
end if -- x>0
end tell -- sheet
end repeat -- i
end tell -- document
return {missing value, missing value, missing value, missing value}
end getSelection
--=====
on parleAnglais()
local z
try
tell application "Numbers" to set z to localized string "Cancel"
on error
set z to "Cancel"
end try
return (z is not "Annuler")
end parleAnglais
--=====
on decoupe(t, d)
local oTIDs, l
set oTIDs to AppleScript's text item delimiters
set AppleScript's text item delimiters to d
set l to text items of t
set AppleScript's text item delimiters to oTIDs
return l
end decoupe
--=====
on recolle(l, d)
local oTIDs, t
set oTIDs to AppleScript's text item delimiters
set AppleScript's text item delimiters to d
set t to l as text
set AppleScript's text item delimiters to oTIDs
return t
end recolle
--=====
--[/SCRIPT]
Yvan KOENIG (VALLAURIS, France) mercredi 23 février 2011 10:18:36 -
How to find first and last date of a fiscal week using SQL
Hello,
I want information about FISCAL Week, means a Week based on ISO standard. I know format strings ‘IW’ or ‘IYYY’ gives fiscal week and fiscal year respectively from a given date. But I want to find the first and last date of a fiscal week. Say suppose I have a fiscal week is 2, and fiscal year is 2008, how to find the start and end date of the given fiscal week.
Any kind of help would be greatly appreciable.
Thanks,
Princedavide gislon wrote:
The following query evaluate the begin of a fisical week, where &year and &week are respectively the year and week you want to calculate.
To evaluate the end of the week you have to add 6.
Note that my database is set to have monday as day number 1 of the week, and sunday as day number 7; if your database settings are different you should modify the query accordingly.
SELECT CASE TO_CHAR(TO_DATE('&year','YYYY'),'D')
WHEN '1' THEN TO_DATE('&year','YYYY')+((&week-1)*7)
WHEN '2' THEN TO_DATE('&year','YYYY')+((&week-1)*7-1)
WHEN '3' THEN TO_DATE('&year','YYYY')+((&week-1)*7-2)
WHEN '4' THEN TO_DATE('&year','YYYY')+((&week-1)*7-3)
WHEN '5' THEN TO_DATE('&year','YYYY')+((&week-1)*7+3)
WHEN '6' THEN TO_DATE('&year','YYYY')+((&week-1)*7+2)
WHEN '7' THEN TO_DATE('&year','YYYY')+((&week-1)*7+1)
END BEGIN_FISICAL_WEEK
FROM DUAL
Hope this is helpful.
Cheers,
Davide
Edited by: davide gislon on 08-Jan-2009 07:19Your query does nothing you say it does. TO_DATE('&year','YYYY') returns first day of the current month for year &year. And the only reason it returns January 1, &year is that we are currently in January:
SQL> select TO_DATE('&year','YYYY') from dual
2 /
Enter value for year: 2005
old 1: select TO_DATE('&year','YYYY') from dual
new 1: select TO_DATE('2005','YYYY') from dual
TO_DATE('
01-JAN-05
SQL> As soon as we roll into February:
SQL> alter system set fixed_date = '2009-2-1' scope=memory
2 /
System altered.
SQL> select sysdate from dual
2 /
SYSDATE
01-FEB-09
SQL> select TO_DATE('&year','YYYY') from dual
2 /
Enter value for year: 2005
old 1: select TO_DATE('&year','YYYY') from dual
new 1: select TO_DATE('2005','YYYY') from dual
TO_DATE('
01-FEB-05
SQL> alter system set fixed_date = NONE scope=both
2 /
System altered.
SQL> select sysdate from dual
2 /
SYSDATE
08-JAN-09
SQL> But even if TO_DATE('&year','YYYY') would always return January 1, &year, or you would fix it to TO_DATE('0101&year','MMDDYYYY') it still would be wrong. ISO week rules are
If January 1 falls on a Friday, Saturday, or Sunday, then the week including January 1 is the last week of the previous year, because most of the days in the week belong to the previous year.
If January 1 falls on a Monday, Tuesday, Wednesday, or Thursday, then the week is the first week of the new year, because most of the days in the week belong to the new year.Therefore, next year:
SQL> DEFINE YEAR=2010
SQL> DEFINE WEEK=1
SQL> ALTER SESSION SET NLS_TERRITORY=GERMANY -- enforce Monday as first day of the week
2 /
Session altered.
SQL> SET VERIFY OFF
SQL> SELECT CASE TO_CHAR(TO_DATE('0101&&year','MMDDYYYY'),'D')
2 WHEN '1' THEN TO_DATE('0101&&year','MMDDYYYY')+((&&week-1)*7)
3 WHEN '2' THEN TO_DATE('0101&&year','MMDDYYYY')+((&&week-1)*7-1)
4 WHEN '3' THEN TO_DATE('0101&&year','MMDDYYYY')+((&&week-1)*7-2)
5 WHEN '4' THEN TO_DATE('0101&&year','MMDDYYYY')+((&&week-1)*7-3)
6 WHEN '5' THEN TO_DATE('0101&&year','MMDDYYYY')+((&&week-1)*7+3)
7 WHEN '6' THEN TO_DATE('0101&&year','MMDDYYYY')+((&&week-1)*7+2)
8 WHEN '7' THEN TO_DATE('0101&&year','MMDDYYYY')+((&&week-1)*7+1)
9 END BEGIN_FISICAL_WEEK
10 FROM DUAL
11 /
BEGIN_FI
04.01.10
SQL> SELECT TRUNC(TO_DATE('0101&&year','MMDDYYYY'),'IW') FROM DUAL
2 /
TRUNC(TO
28.12.09
SQL> 2 user10772980:
Use:
SELECT TRUNC(TO_DATE('0101&&year','MMDDYYYY'),'IW') + (&&week-1)*7 FISCAL_YEAR_&&YEAR._WEEK_&&WEEK
FROM DUAL
FISCAL_YEAR_2010_WEEK_1
28.12.09
SQL> SY. -
Swapping the first and last characters in a column
Hi,
Fairly new to T-SQL and i want to swap the first and last characters in a column.
Thanks
Umar JavedLikewise i have also tried your suggestion and i still seem to be getting errors:
IF (@TYPE = 'SCRAMBLE')
BEGIN
DECLARE @SQLCOMMAND VARCHAR(2000)
SET @SQLCOMMAND = 'UPDATE ' + @TABLENAME + ' SET ' + @VALUE +
STUFF(STUFF(@VALUE,1,1,RIGHT(@VALUE,1)),LEN(@VALUE),1,LEFT(@VALUE,1))
EXECUTE(@SQLCOMMAND)
END
Umar Javed
Please post the errors.
EDIT: Actually looking at your code this will bring errors:
IF (@TYPE = 'SCRAMBLE')
BEGIN
DECLARE @SQLCOMMAND VARCHAR(2000)
SET @SQLCOMMAND = 'UPDATE ' + @TABLENAME + ' SET ' + @VALUE + ' = STUFF(STUFF('+@VALUE+',1,1,RIGHT('+@VALUE+',1)),LEN('+@VALUE+'),1,LEFT('+@VALUE+',1))'
PRINT @SQLCOMMAND
EXECUTE(@SQLCOMMAND)
END
I've also added a print command so it will show you what the code looks like upon concatenation. It's much easier to debug this way. -
How to get the first and last record
Hai All
I have table called T1 and there are more than 8 lakhs records and i have a column called Timestamp so i need to get the first record value and time stampvalue and last record and time stamp value so that i can conclude that For Example
form 13 june to 15 june data are here
Kind Regards
SrikkanthMSomething like this can also indicate the first and last rows as you query...
SQL> select empno, ename, hiredate
2 ,case row_number() over (order by hiredate)
3 when 1 then 'First Row'
4 when count(*) over () then 'Last Row'
5 end as flag
6 from emp;
EMPNO ENAME HIREDATE FLAG
7369 SMITH 17/12/1980 00:00:00 First Row
7499 ALLEN 20/02/1981 00:00:00
7521 WARD 22/02/1981 00:00:00
7566 JONES 02/04/1981 00:00:00
7698 BLAKE 01/05/1981 00:00:00
7782 CLARK 09/06/1981 00:00:00
7844 TURNER 08/09/1981 00:00:00
7654 MARTIN 28/09/1981 00:00:00
7839 KING 17/11/1981 00:00:00
7900 JAMES 03/12/1981 00:00:00
7902 FORD 03/12/1981 00:00:00
7934 MILLER 23/01/1982 00:00:00
7788 SCOTT 19/04/1987 00:00:00
7876 ADAMS 23/05/1987 00:00:00 Last Row
14 rows selected.
SQL> -
How can I display the first and last name using a paramater as employee ID?
Hi SAP,
I have a parameter that is called {? Employee ID}. What I want to do is display the first and last name based on the employee ID value entered in {? Employee ID} in the page header of the report. Right now, when I put the following formula in the page header only some pages get the right result while other pages dont....
if table.employeeid = {? Employee ID} then
table.firstname" "table.lastname
It appears as though if the first record in the details section on the beginning of each page happens to be the employee under {? Employee ID} then it prints it correctly, if it isn't I get a null value in the page header.
Anyone have any ideas?
ZHi Try this,
Whileprintingrecords;
if ={?EmpID} then
Also check the option "Default values for null" in the formula editor.
Regards,
Vinay -
Can only see first and last frame of clip in the timeline HELP PLEASE
Hi, my first time and I did look for an answer, but can't find one. I have premiere elements 4 and I am trying out ver. 9. In ver. 4 the clips in the timelin shows all the frames, but in ver. 9 it only shows the first and last frame of the clips. Is there any way to make all the frames show. By "all the frames", I mean the clips fill with frames.I liked to see all the frames in the timeline, it is easier for me to select and trim the bits out.
My specs are Core 2 Duo 6750, Nvidia 8600GTS, 4G Ram, Vista Home Premium. 3 HDD 3TB.
Thank you for answering
WernerAs for the GUI, PrE had one more like PrPro (the early versions), up through PrE 3. With PrE 4, they streamlined the GUI (and some of the operation), and went with the "dark look." PrPro went in that direction starting with CS3, and now, the two programs' GUI looks more alike - darker. Personally, I like PrPro 2.0's brighter GUI. Now, one can alter the brightness, but the contrast can work against doing much of that - give me the lighter GUI....
The look of PrE 4 thru PrE 9 is very similar, though things have moved about some. Still the look is similar. Same for PrPro CS 3 through CS 5.5.
As for the trial, things have changed in PrPro, as of CS 5.5. Once, the PrPro trial was very crippled, but had no watermark. No more. No crippling, and still no watermark. The trial for PrE is far less crippled, but does have the watermark. We do not know what changes might be coming with the trial of PrE10. We will just have to wait and see. One great option that Adobe offers is the 30-day, money-back guarantee. If you buy Premiere (either flavor), and use it for 29 days, but do not like it, then you return it for your money back. This is the full-paid version (both flavors) with nothing crippled, and no watermark. Not that many companies make such an offer. Basically, on can use the trial for 30 days, to see some of the powers of the program, and then buy it, and try it fully for another 29 days. If not completely satisfied, they get their money back - essentially a 59 day trial.
Were I doing AVCHD, I would definitely look at buying PrE 9, and giving it a 29 day shakedown. The only caveat is that AVCHD requires a lot of computer "horsepower," and not all computers (especially if more than a year, or so old) are up to that task. I find it amazing that a consumer format, like AVCHD, requires more computer power to process, than most professional formats, until one gets up to, say RED 2K/4K. However, that is the nature of the H.264 CODEC, and by that, I mean all H.264, not just the AVCHD version.
Good luck and happy editing,
Hunt
Maybe you are looking for
-
How can i print the e-mail address book
I need to be able to share the address book. How can I print the contents
-
SAP B1 Drag & Relate causes DMP Error
SBO Version: 8.82 PL09 Forum, We have noticed for windows 7 / windows 8.1 machines that when we come to use the 'Drag & Relate' facility, it is causing those SAP clients to crash with the following error: I have found on this forum a thread which ind
-
I have a EOS Rebel 300D and need drivers...
I have an EOS Rebel 300D and I just re-installed the program on to my laptop because my laptop had a virus and I had to have everything re-installed. However, now I can't seem to find the correct drivers. Does anyone know where I can find them? I hav
-
Ggraphic chart Java project planning ?
Please, does anyone know of a link to the conventional chart symbols for project planning in Java Programming ? Or a link to any assistance for graphic chart Java project planning.
-
What is the documents folder??
I was using an app, I don't remember which one ... Maybe notes plus or goodreader ... oh it may have been pages possibly? Anyway, I went to export a file and one of the options was "ipad documents folder." What does that mean!?!?! Thanks!