Select stmts with Having Clause
Hi,
Can some body help me to improve the performance of the below query...
select t.seq_no,t.contract_id,t.date_from from test_plan_tab t
group by t.seq_no,t.contract_id,t.date_from
having (select count(*)
from test_plan_tab p
where p.contract_id = t.contract_id
and p.date_from = t.date_from) > 1
The having clause will reduce the performance of the above query I guess...
Thanks And Best Regards,
/Dinesh...
If Seq_no is unique then try this
SELECT MIN(t.seq_no),contract_id,t.date_from,count(*) from test_plan_tab t
group by t.contract_id,t.date_from
HAVING COUNT(*) > 1or
you can try as fsitja said, but you can omit the group by as the partition has already been done on grouping columns
SELECT seq_no, contract_id, date_from
FROM (SELECT t.seq_no, t.contract_id, t.date_from, COUNT(*) over(PARTITION BY contract_id, date_from) tot
FROM test_plan_tab t)
WHERE tot > 1Regards,
Prazy
Similar Messages
-
Use of Select stmts with Update stmts
Hi,
I want to execute the following update stmt...
UPDATE Test1_tab a
SET a.invpln_seq_no = (SELECT b.seq_no
FROM Test2_tab b
WHERE b.contract_id = a.contract_id
AND b.date_from = a.period_from_date)
WHERE a.invpln_seq_no != (SELECT b.seq_no
FROM Test2_tab b
WHERE b.contract_id = a.contract_id
AND b.date_from = a.period_from_date)
Here the problem is I have used 'SELECT b.seq_no FROM Test2_tab b WHERE b.contract_id = a.contract_id AND b.date_from = a.period_from_date' twice, one in the SET clause and the other one in WHERE clause...But it is the same SELECT stmt...So this same Select stmt runs twice when I run the whole update stmt I guess. Is there a way to do the above update, where it runs the SELECT stmt only once...
Any input is highly appreciated...
Thanks And Best Regards,
/Dinesh...Then you can use Merge statement instead.
try this
merge into test1_tab t1
using
(SELECT a.rowid,b.seq_no SEQ_DEST
FROM test1_tab a,test2_tab b
WHERE b.contract_id = a.contract_id
AND b.date_from = a.period_from_date
AND a.invpln_seq_no != b.seq_no) t2
ON (t1.rowid=t2.rowid)
WHEN MATCHED THEN
UPDATE SET t1.invpln_seq_no=t2.seq_destor if you are sure that sno is a unique key with out any duplicates and if you are going to perform one time manual update then you can use an undocumented hint /*+ bypass_ujvc */ to do this.
*DO NOT include this code if you are about to add it in a production procedure or a function
UPDATE /*+ bypass_ujvc */ (SELECT a.invpln_seq_no SEQ_SRC,b.seq_no SEQ_DEST FROM test1_tab a,test2_tab b
WHERE b.contract_id = a.contract_id
AND b.date_from = a.period_from_date
AND a.invpln_seq_no != b.seq_no)
SET SEQ_SRC = SEQ_DESTRegards,
Prazy -
Issue in select query with where clause
Hi guys,
I'm facing an issue while using select query with the where clause. When I'm selecting all the data from the table it returns the correct result. But when I'm using the where clause to get the specific rows from the table it returns no rows. But the data I'm trying to fetch using the where condition exists in the table.
Here is my query which causing the issue,
select * from mytable where myfield = 'myvalue'
But if I use the following query it returns the result correctly.
select * from mytable
Also the myfield value 'myvalue' exists in the table.
I have tried by running this query in both SQL Developer and SQL Plus. I have tried this query in mssql as well. It works perfectly and returns correct result sets for both the queries I have mentioned above. I'm unable to predict the issue as I'm new to ORACLE. Please help.
Thanks,
Ram.Hi Ram,
I experienced an issue similar to this with a varchar2 field. Some of our records had a hidden newline character at the end of them, which was making queries like the one below fail:
select * from employees
where email = '[email protected]'The best way I found to detect this was to use
select 'XX'||email||'XX' from employeesTo make sure that there were no newlines. But that is just a guess. If you could provide some example table data and the outputs of your selects, it would be helpful.
Jeff -
Select query with UNION clause in database adapter
Friends,
I have got a SQL query with two UNION clause withing it. like
select a,b,c
from a
union
select a,b,c
from b
The schema generated is like below in sequence
<element>a</element>
<element>b</element>
<element>c</element>
<element>a</element>
<element>b</element>
<element>c</element>
So, the columns from different select queries joined with UNION clause are all appeared in schema instead of the distinct columns.
Is there any way around to solve this issue ? or will need to with DB function/procedure.I think I know what you are saying but your example doesn't make sense, your SQL should produce something like
I had to change a, b, c with elementA, elementB, elementC as a and b are reserved html tags.
<elementA>DateA</elementA>
<elementB>DataB</elementB>
<elementC>DataC</elementC>
...What is the result of the query when you run it in SQLPlus? Is it what you expect?
cheers
James -
Select sdo_nn with where-clause on large table
Hi spatial-experts,
I've following problem. I use a table with more than 2.500.000 dataset. Every dataset represents one point (SDO_GEOMETRY, SDO_POINT_TYPE) and have further (text) information. (PI (point of interest) table from TeleAtlas mn_pi)
Following Select works fine:
SELECT /*+ ORDERED NO_INDEX(pi IX_PI_FEATTYP) */
sdo_nn_distance(1) distance,
id, feattyp, arnamelc, name, stname, stnamelc, hsnum, postcode
FROM multinet.mn_pi pi
WHERE
pi.feattyp IN ( 9373,9374)
AND
SDO_NN(
pi.geom,
SDO_GEOMETRY( 2001, 8307, SDO_POINT_TYPE(613.86865234375/60, 3002.94677734375/60, NULL), NULL, NULL),
'sdo_batch_size=0', 1) = 'TRUE'
AND rownum = 1
ORDER BY distance
(P.S. IX_PI_FEATTYP is an index on column feattyp, here not used. When I'm using it the select do not work (it last very long...))
When I now modify the where clause to an pi which feat type that does not exists (no entry in table) the select lasts very long (I canceled the select after 5 minutes).
for example: pi.feattyp = 9756
Otherwise I add a further where clause like
AND arnamelc = 'ITA'
the select also works very long. The point are now in italy. refrence point is in germany and is more than 500km away.
Are there some solutions to solve this problems
(should I use for every feat type a own table)?
Why is the select so slow?
Thanks for all helpfully answers,
MatthiasHi Matthias,
When you use nearest neighbor, Oracle will use the spatial index to find the nearest neighbor that meets the query criteria. It probes into the index, calculates distances, and returns data in distance order.
Using SDO_BATCH_SIZE, it keeps going back to the database, returning more and more records in distance order until the other predicates are satisfied (in your case, pi.feattyp IN ( 9373,9374).
When you specified pi.feattyp = 9756 (which doesn't exist), you told Oracle to keep going and calculating distances for each of the more than 2.500.000 records in the the data set (you killed it after 5 minutes).
I don't know why adding: AND arnamelc = 'ITA' caused Oracle to take extra time. Sometimes I will do a: set autotrace trace exp
then compare plans for something that runs quickly vs. something that runs slowly. If you want to post the plans for the fast and slow versions it might be interesting to look at.
My guess is you may want to look at a solution that incorporates various possibilities. For instance, if there are only a few of some feattyp values, you may want to select those using the non-spatial index then use sdo_geom.sdo_distance to find the closest point rather than risk having to look through a few million values for a match.
I'm sure other people have thoughts as well...
Kind regards,
Dan -
How does select stmt with for all entries uses Indexes
Hello all,
I goes through a number of documents but still confused how does select for all entries uses indexes if fields are not in sequences. i got pretty much the same results if i take like two cases on Hr tables HRP1000 and HRP1001(with for all entries based upon hrp1000). Here is the sequence of index fields on hrp1001 (MANDT, OTYPE, OBJID, PLVAR, RSIGN, RELAT, ISTAT, PRIOX, BEGDA, ENDDA, VARYF, SEQNR). in second case objid field is in sequence as in defined Index but i dont see significant increase in field even though the number of records are around 30000. My question is does it make a differrence to use field sequence (same as in table indexes) in comparison to redundant field sequence (not same as defined in table indexes), secondly how we can ge tto know if table index is used in Select for entries query i tried Explain in ST05 but its not clear if it uses any index at all in hrp1001 read.
here is the sample code i use to get test results.
test case 1
REPORT zdemo_perf_select.
DATA: it_hrp1000 TYPE STANDARD TABLE OF hrp1000 WITH HEADER LINE.
DATA: it_hrp1001 TYPE STANDARD TABLE OF hrp1001 WITH HEADER LINE.
DATA: it_hrp1007 TYPE STANDARD TABLE OF hrp1007 WITH HEADER LINE.
DATA: it_pa0000 TYPE STANDARD TABLE OF pa0000 WITH HEADER LINE.
DATA: it_pa0001 TYPE STANDARD TABLE OF pa0001 WITH HEADER LINE.
DATA: it_pa0002 TYPE STANDARD TABLE OF pa0002 WITH HEADER LINE.
DATA: it_pa0105_10 TYPE STANDARD TABLE OF pa0105 WITH HEADER LINE.
DATA: it_pa0105_20 TYPE STANDARD TABLE OF pa0105 WITH HEADER LINE.
DATA: t1 TYPE timestampl,
t2 TYPE timestampl,
t3 TYPE timestampl
SELECT * FROM hrp1000 CLIENT SPECIFIED INTO TABLE it_hrp1000 bypassing buffer
WHERE mandt EQ sy-mandt AND
plvar EQ '01' AND
otype EQ 'S'AND
istat EQ '1' AND
begda <= sy-datum AND
endda >= sy-datum AND
langu EQ 'EN'.
GET TIME STAMP FIELD t1.
SELECT * FROM hrp1001 CLIENT SPECIFIED INTO TABLE it_hrp1001 bypassing buffer
FOR ALL ENTRIES IN it_hrp1000
WHERE mandt EQ sy-mandt AND
otype EQ 'S' AND
* objid EQ it_hrp1000-objid and
plvar EQ '01' AND
rsign EQ 'B' AND
relat EQ '007' AND
istat EQ '1' AND
begda LT sy-datum AND
endda GT sy-datum and
sclas EQ 'C' and
objid EQ it_hrp1000-objid.
* %_hints mssqlnt 'INDEX(HRP1001~0)'.
*delete it_hrp1001 where sclas ne 'C'.
GET TIME STAMP FIELD t2.
t3 = t1 - t2.
WRITE: 'Time taken - ', t3.
test case 2
REPORT zdemo_perf_select.
DATA: it_hrp1000 TYPE STANDARD TABLE OF hrp1000 WITH HEADER LINE.
DATA: it_hrp1001 TYPE STANDARD TABLE OF hrp1001 WITH HEADER LINE.
DATA: it_hrp1007 TYPE STANDARD TABLE OF hrp1007 WITH HEADER LINE.
DATA: it_pa0000 TYPE STANDARD TABLE OF pa0000 WITH HEADER LINE.
DATA: it_pa0001 TYPE STANDARD TABLE OF pa0001 WITH HEADER LINE.
DATA: it_pa0002 TYPE STANDARD TABLE OF pa0002 WITH HEADER LINE.
DATA: it_pa0105_10 TYPE STANDARD TABLE OF pa0105 WITH HEADER LINE.
DATA: it_pa0105_20 TYPE STANDARD TABLE OF pa0105 WITH HEADER LINE.
DATA: t1 TYPE timestampl,
t2 TYPE timestampl,
t3 TYPE timestampl
SELECT * FROM hrp1000 CLIENT SPECIFIED INTO TABLE it_hrp1000 bypassing buffer
WHERE mandt EQ sy-mandt AND
plvar EQ '01' AND
otype EQ 'S'AND
istat EQ '1' AND
begda <= sy-datum AND
endda >= sy-datum AND
langu EQ 'EN'.
GET TIME STAMP FIELD t1.
SELECT * FROM hrp1001 CLIENT SPECIFIED INTO TABLE it_hrp1001 bypassing buffer
FOR ALL ENTRIES IN it_hrp1000
WHERE mandt EQ sy-mandt AND
otype EQ 'S' AND
objid EQ it_hrp1000-objid and
plvar EQ '01' AND
rsign EQ 'B' AND
relat EQ '007' AND
istat EQ '1' AND
begda LT sy-datum AND
endda GT sy-datum and
sclas EQ 'C'." and
* objid EQ it_hrp1000-objid.
* %_hints mssqlnt 'INDEX(HRP1001~0)'.
*delete it_hrp1001 where sclas ne 'C'.
GET TIME STAMP FIELD t2.
t3 = t1 - t2.
WRITE: 'Time taken - ', t3.Mani wrote:
Thank you for your answer, its very helpful but i am still nor sure how does parameter rsdb/max_blocking_factor affect records size.
Hi,
The blocking affects the size of the statement and the memory structures for returning the result.
So if your itab has 500 rows and your blocking is 5, the very same statement will be executed 100 times.
Nothing good or bad about this so far.
Assume, your average result for an inlist 5 statement is 25 records with an average size of 109 bytes.
You average result size will be 2725 byte plus overhead which will nearly perfectly fit into two 1500 byte ethernet frames.
Nothing to do in this case.
Assume your average result for an inlist 5 statement is 7 records with an average size of 67 bytes.
You average result size will be ~ 470 byte plus overhead which will only fill 1/3 of a 1500 byte ethernet frame.
In this case, setting the blocking to 12 ... 15 will give you 66% network transfer performance gain,
and reduces the number of calls to the DB by 50%, giving additional benefit.
Now this is an extreme example. The longer the average row length is, the lower will be the average loss in the network.
You have the same effects in memory structures, but on that layer you are fighting single micro seconds instead of
hundreds of these, so in real life it is rarely measurable.
Depending on table-statistics, oracle might decide for short inlists to use a concatanation instead of an inlist.
This is supposed to be more costy, but I never had a case where I could proove a big difference.
Values from 5 to 15 for blocking seem to be ok for me. If you have special statements in customer coding,
it #might# be benefitial to do the mentioned calculations and do some network tracing to see if you can squeeze your
network efficiency by tuning the blocking.
If you have jumbo frames enabled, it might be worth to be analyzed as well.
If you are only on a DB-CI system that is loopback connected to the DB, I doubt there might be a big outcome.
Hope this helps
Volker -
I have a test data, like this
with t as (
select 1 tp, 0 sm_1, 1 sm_2, 'a' code from dual
union all
select 1 tp, 0 sm_1, 2 sm_2, 'b' from dual
union all
select 2 tp, 3 sm_1, 0 sm_2, 'c' from dual
union all
select 3 tp, 0 sm_1, 2 sm_2, 'a' from dual
union all
select 4 tp, 0 sm_1, 1 sm_2, 'a' from dual
union all
select 4 tp, 2 sm_1, 3 sm_2,'b' from dual
union all
select 4 tp, 2 sm_1, 3 sm_2, 'c' from dual
union all
select 5 tp, 0 sm_1, 0 sm_2, 'a' from dual
union all
select 5 tp, 0 sm_1, 0 sm_2, 'b' from dual
union all
select 5 tp, 0 sm_1, 0 sm_2, 'c' from dual)
SQL> with t as (
2 select 1 tp, 0 sm_1, 1 sm_2, 'a' code from dual
3 union all
4 select 1 tp, 0 sm_1, 2 sm_2, 'b' from dual
5 union all
6 select 2 tp, 3 sm_1, 0 sm_2, 'c' from dual
7 union all
8 select 3 tp, 0 sm_1, 2 sm_2, 'a' from dual
9 union all
10 select 4 tp, 0 sm_1, 1 sm_2, 'a' from dual
11 union all
12 select 4 tp, 2 sm_1, 3 sm_2,'b' from dual
13 union all
14 select 4 tp, 2 sm_1, 3 sm_2, 'c' from dual
15 union all
16 select 5 tp, 0 sm_1, 0 sm_2, 'a' from dual
17 union all
18 select 5 tp, 0 sm_1, 0 sm_2, 'b' from dual
19 union all
20 select 5 tp, 0 sm_1, 0 sm_2, 'c' from dual)
21 select tp, SUM(sm_1), SUM(sm_2), code from t
22 group by tp, code
23 /
TP SUM(SM_1) SUM(SM_2) CODE
1 0 1 a
1 0 2 b
2 3 0 c
3 0 2 a
4 0 1 a
4 2 3 b
4 2 3 c
5 0 0 a
5 0 0 b
5 0 0 c
10 rows selected
SQL>
And I want to get this result
TP SUM(SM_1) SUM(SM_2) CODE
1 0 1 a
1 0 2 b
2 3 0 c
3 0 2 a
4 0 1 a
4 2 3 b
4 2 3 c
5 0 0 a
E.g. if SM_1 = SM_2(all of the rows) In group of tp, then return random rows with tp = 5, if
5 0 0 c
5 1 2 a
5 3 1 b
then return
5 1 2 a
5 3 1 b
And I don't undersatnd how it's do with Having Clause.
Thank you!SQL> with t as (
2 select 1 tp, 0 sm_1, 1 sm_2, 'a' code from dual
3 union all
4 select 1 tp, 0 sm_1, 2 sm_2, 'b' from dual
5 union all
6 select 2 tp, 3 sm_1, 0 sm_2, 'c' from dual
7 union all
8 select 3 tp, 0 sm_1, 2 sm_2, 'a' from dual
9 union all
10 select 4 tp, 0 sm_1, 1 sm_2, 'a' from dual
11 union all
12 select 4 tp, 2 sm_1, 3 sm_2,'b' from dual
13 union all
14 select 4 tp, 2 sm_1, 3 sm_2, 'c' from dual
15 union all
16 select 5 tp, 0 sm_1, 0 sm_2, 'a' from dual
17 union all
18 select 5 tp, 0 sm_1, 0 sm_2, 'b' from dual
19 union all
20 select 5 tp, 0 sm_1, 0 sm_2, 'c' from dual)
21 select tp, sm_1, sm_2, code
22 from (select tp,
23 SUM(sm_1) sm_1,
24 SUM(sm_2) sm_2,
25 code,
26 count(*) over (partition by tp) ct_tp,
27 count(*) over (partition by tp, SUM(sm_1), SUM(sm_2)) ct,
28 row_number() over (partition by tp order by null) rn
29 from t
30 group by tp, code)
31 where decode(ct,ct_tp,rn,1)=1
32 and case when sm_1 = 0 and sm_2 = 0 and ct_tp-ct > 0 then 0 else 1 end = 1;
TP SM_1 SM_2 C
1 0 1 a
1 0 2 b
2 3 0 c
3 0 2 a
4 0 1 a
4 2 3 b
4 2 3 c
5 0 0 a
8 rows selected.
SQL> with t as (
2 select 1 tp, 0 sm_1, 1 sm_2, 'a' code from dual
3 union all
4 select 1 tp, 0 sm_1, 2 sm_2, 'b' from dual
5 union all
6 select 2 tp, 3 sm_1, 0 sm_2, 'c' from dual
7 union all
8 select 3 tp, 0 sm_1, 2 sm_2, 'a' from dual
9 union all
10 select 4 tp, 0 sm_1, 1 sm_2, 'a' from dual
11 union all
12 select 4 tp, 2 sm_1, 3 sm_2,'b' from dual
13 union all
14 select 4 tp, 2 sm_1, 3 sm_2, 'c' from dual
15 union all
16 select 5 tp, 0 sm_1, 0 sm_2, 'a' from dual
17 union all
18 select 5 tp, 1 sm_1, 0 sm_2, 'b' from dual
19 union all
20 select 5 tp, 2 sm_1, 0 sm_2, 'c' from dual)
21 select tp, sm_1, sm_2, code
22 from (select tp,
23 SUM(sm_1) sm_1,
24 SUM(sm_2) sm_2,
25 code,
26 count(*) over (partition by tp) ct_tp,
27 count(*) over (partition by tp, SUM(sm_1), SUM(sm_2)) ct,
28 row_number() over (partition by tp order by null) rn
29 from t
30 group by tp, code)
31 where decode(ct,ct_tp,rn,1)=1
32 and case when sm_1 = 0 and sm_2 = 0 and ct_tp-ct > 0 then 0 else 1 end = 1;
TP SM_1 SM_2 C
1 0 1 a
1 0 2 b
2 3 0 c
3 0 2 a
4 0 1 a
4 2 3 b
4 2 3 c
5 1 0 b
5 2 0 c
9 rows selected.Nicolas. -
Having clause with Analytic function
can you pls let me know if we can use HAVING clause with analytic function
select eid,empno,sum(sal) over(partition by year)
from employee
where dept = 'SALES'
having sum(sal) > 10000I m getting error while using the above,
IS that we can use HAVING clause with partition by
Thanks in advanceYour having clause isn't using an analytical function, is using a regular aggregate function.
You also can't use analytical functions in the where clause or having clause like that as they are windowing functions and belong at the top of the query.
You would have to wrap the query to achieve what you want e.g.
SQL> ed
Wrote file afiedt.buf
1 select deptno, total_sal
2 from (
3 select deptno,sum(sal) over (partition by deptno) as total_sal
4 from emp
5 )
6 group by deptno, total_sal
7* having total_sal > 10000
SQL> /
DEPTNO TOTAL_SAL
20 10875
SQL> -
Group by clause and having clause in select
hi frnds
plz give me some information of group by and having clause used in select statement with example
thanksThe Open SQL statement for reading data from database tables is:
SELECT <result>
INTO <target>
FROM <source>
[WHERE <condition>]
[GROUP BY <fields>]
[HAVING <cond>]
[ORDER BY <fields>].
The SELECT statement is divided into a series of simple clauses, each of which has a different part to play in selecting, placing, and arranging the data from the database.
You can only use the HAVING clause in conjunction with the GROUP BY clause.
To select line groups, use:
SELECT <lines> <s1> [AS <a1>] <s2> [AS <a2>] ...
<agg> <sm> [AS <am>] <agg> <sn> [AS <an>] ...
GROUP BY <s1> <s2> ....
HAVING <cond>.
The conditions <cond> that you can use in the HAVING clause are the same as those in the SELECT clause, with the restrictions that you can only use columns from the SELECT clause, and not all of the columns from the database tables in the FROM clause. If you use an invalid column, a runtime error results.
On the other hand, you can enter aggregate expressions for all columns read from the database table that do not appear in the GROUP BY clause. This means that you can use aggregate expressions, even if they do not appear in the SELECT clause. You cannot use aggregate expressions in the conditions in the WHERE clause.
As in the WHERE clause, you can specify the conditions in the HAVING clause as the contents of an internal table with line type C and length 72.
Example
DATA WA TYPE SFLIGHT.
SELECT CONNID
INTO WA-CONNID
FROM SFLIGHT
WHERE CARRID = 'LH'
GROUP BY CONNID
HAVING SUM( SEATSOCC ) > 300.
WRITE: / WA-CARRID, WA-CONNID.
ENDSELECT.
This example selects groups of lines from database table SFLIGHT with the value LH for CARRID and identical values of CONNID. The groups are then restricted further by the condition that the sum of the contents of the column SEATSOCC for a group must be greater than 300.
The <b>GROUP BY</b> clause summarizes several lines from the database table into a single line of the selection.
The GROUP BY clause allows you to summarize lines that have the same content in particular columns. Aggregate functions are applied to the other columns. You can specify the columns in the GROUP BY clause either statically or dynamically.
Specifying Columns Statically
To specify the columns in the GROUP BY clause statically, use:
SELECT <lines> <s1> [AS <a 1>] <s 2> [AS <a 2>] ...
<agg> <sm> [AS <a m>] <agg> <s n> [AS <a n>] ...
GROUP BY <s1> <s 2> ....
To use the GROUP BY clause, you must specify all of the relevant columns in the SELECT clause. In the GROUP BY clause, you list the field names of the columns whose contents must be the same. You can only use the field names as they appear in the database table. Alias names from the SELECT clause are not allowed.
All columns of the SELECT clause that are not listed in the GROUP BY clause must be included in aggregate functions. This defines how the contents of these columns is calculated when the lines are summarized.
Specifying Columns Dynamically
To specify the columns in the GROUP BY clause dynamically, use:
... GROUP BY (<itab>) ...
where <itab> is an internal table with line type C and maximum length 72 characters containing the column names <s 1 > <s 2 > .....
Example
DATA: CARRID TYPE SFLIGHT-CARRID,
MINIMUM TYPE P DECIMALS 2,
MAXIMUM TYPE P DECIMALS 2.
SELECT CARRID MIN( PRICE ) MAX( PRICE )
INTO (CARRID, MINIMUM, MAXIMUM)
FROM SFLIGHT
GROUP BY CARRID.
WRITE: / CARRID, MINIMUM, MAXIMUM.
ENDSELECT.
regards
vinod -
I'm having problems (1) selecting onscreen text, (2) resizing menu boxes and selecting menues with the cursor. I'm not able to select menus and move them. I'm not sure how to correct this.
1) This is because of software version 1.1. See this
thread for some options as to how to go back to 1.0,
which will correct the problem...
http://discussions.apple.com/thread.jspa?threadID=3754
59&tstart=0
2) This tends to happen after videos. Give the iPod a
minute or two to readjust. It should now be more
accurate.
3) This?
iPod shows a folder icon with exclamation
point
4) Restore the iPod
5) Try these...
iPod Only Shows An Apple Logo and Will Not Start
Up
iPod Only Shows An Apple Logo
I think 3,4, and 5 are related. Try the options I
posted for each one.
btabz
I just noticed that one of the restore methods you posted was to put it into Disk Mode First rather than just use the resstore straight off, I Have tried that and seems to have solved the problem, If it has thank you. previously I have only tried just restoring it skipping this extra step. Hope my iPod stays healthy, if it doesnt its a warrenty job me thinks any way thanks again -
Error with select stmt.
Hi All,
I am getting this error , can you please tell me what I am doing wrong with the select stmt.
SELECT AFKDAT ANETWR B~KZWI1
FROM VBRK AS A INNER JOIN VBRP AS B ON
AVBELN = BVBELN
INTO (IOUT-FKDAT, IOUT-NETWR, IOUT-KZWI1)
WHERE B~VBELN = IOUT-VBELV
AND B~POSNR = ISDOC-POSNR.
Incorrect nesting: Before the statement "ENDIF", the structure
introduced by "SELECT" must be concluded by "ENDSELECT". -
Thanks
Veni.Hi All,
I tried INTO CORRESPONDING FIELDS OF IOUT
but with this also same error is comming. I am sending part of code.
Please help me.
Thanks
Veni.
TABLES: VBAK, VBAP, KNA1, VBRK, VBRP, VBFA.
DATA: BEGIN OF ISDOC OCCURS 0,
VBELN LIKE VBAK-VBELN,
POSNR LIKE VBAP-POSNR,
KUNNR LIKE VBAK-KUNNR,
ERDAT LIKE VBAK-ERDAT,
BSTNK LIKE VBAK-BSTNK,
MATNR LIKE VBAP-MATNR,
ARKTX LIKE VBAP-ARKTX.
DATA: END OF ISDOC.
DATA: BEGIN OF IOUT OCCURS 0,
VBELN LIKE VBAK-VBELN,
POSNR LIKE VBAP-POSNR,
KUNNR LIKE VBAK-KUNNR,
NAME1 LIKE KNA1-NAME1,
ERDAT LIKE VBAK-ERDAT,
BSTNK LIKE VBAK-BSTNK,
MATNR LIKE VBAP-MATNR,
ARKTX LIKE VBAP-ARKTX,
VBELV LIKE VBRP-VBELN,
FKDAT LIKE VBRK-FKDAT,
NETWR LIKE VBRK-NETWR,
KZWI1 LIKE VBRP-KZWI1.
DATA: END OF IOUT.
FORM getdata.
SELECT A~VBELN B~POSNR A~KUNNR A~ERDAT A~BSTNK B~MATNR B~ARKTX
FROM VBAK AS A INNER JOIN VBAP AS B ON A~VBELN = B~VBELN
INTO TABLE ISDOC
WHERE A~AUART IN SAUART
AND A~ERDAT IN SERDAT
AND A~KUNNR IN SKUNNR.
SORT ISDOC BY VBELN POSNR.
LOOP AT ISDOC.
MOVE-CORRESPONDING ISDOC TO IOUT.
CLEAR: KNA1.
SELECT SINGLE * FROM KNA1 WHERE KUNNR = ISDOC-KUNNR.
IF SY-SUBRC = 0.
MOVE KNA1-NAME1 TO IOUT-NAME1.
ENDIF.
SELECT VBELN INTO IOUT-VBELV FROM VBFA WHERE VBELV = ISDOC-VBELN
AND POSNV = ISDOC-POSNR
AND VBTYP_N = 'O'.
IF SY-SUBRC = 0.
SELECT A~FKDAT A~NETWR B~KZWI1
FROM VBRK AS A INNER JOIN VBRP AS B ON A~VBELN = B~VBELN
INTO CORRESPONDING FIELDS OF IOUT
* (IOUT-FKDAT, IOUT-NETWR, IOUT-KZWI1)
WHERE B~VBELN = IOUT-VBELV
AND B~POSNR = ISDOC-POSNR.
APPEND IOUT.
CLEAR IOUT.
ENDIF.
ENDLOOP.
ENDFORM. " getdata -
Hi All,
Do you see anything wrong with this select stmt, it is giving me short dump.
DATA: BEGIN OF it_output OCCURS 0,
check TYPE c,
vbeln LIKE likp-vbeln,
lfdat LIKE likp-lfdat,
kunnr LIKE likp-kunnr,
knkli LIKE likp-knkli,
netwr LIKE vbak-netwr,
END OF it_output.
SELECT LIKPVBELN LIKPLFDAT LIKPKUNNR LIKPKNKLI VBAK~NETWR
FROM LIKP
INNER JOIN VBAK ON LIKPVBELN = VBAKVBELN
INTO TABLE IT_OUTPUT
WHERE LIKP~LFDAT IN S_LFDAT
AND LIKP~KUNNR IN S_KUNNR
AND LIKP~LIFSK = P_LIFSK.
Thanks
Veni.Hi
DATA: BEGIN OF it_output OCCURS 0,
One error is here:
<b>*check TYPE c,</b>
vbeln LIKE likp-vbeln,
lfdat LIKE likp-lfdat,
kunnr LIKE likp-kunnr,
knkli LIKE likp-knkli,
netwr LIKE vbak-netwr,
<b>check type c,</b>
END OF it_output.
SELECT LIKPVBELN LIKPLFDAT LIKPKUNNR LIKPKNKLI VBAK~NETWR
FROM LIKP
Another error is here
<b>*INNER JOIN VBAK ON LIKPVBELN = VBAKVBELN</b>
INNER JOIN LIPS ON LIKPVBELN = LIPSVBELN
INNER JOIN VBAK ON LIPSVGBEL = VBAKVBELN
INTO TABLE IT_OUTPUT
WHERE LIKP~LFDAT IN S_LFDAT
AND LIKP~KUNNR IN S_KUNNR
AND LIKP~LIFSK = P_LIFSK.
The link between sales order and delivery is in the item data, field is LIPS-VGBEL
Max -
Urgent Group by Having Clause Fails in Oracle and Works in Sybase
Hello EveryBody I need to select curve data of curve whose date is maximum in that curve so say if i ahve
so if records are
curveid curvename curvedate
1001 test1 12/12/1003
1001 test1 12/13/1003
1002 test2 12/12/2002
1002 test2 12/12/2004
I have query which run well in sybase but oracle screw up...My logic say having clause is use to filter the records of group so it should have worked in oracle.....
Here is query
select curveid,curvename from curve group by curveid having curvedate =max(curve_date)
This give "not a Group by " error in oracle....It work well in sybase...
ORA-00979: not a GROUP BY expression
I have query which use subquery to select these records but i don't want that to use that query
Please helpplease understand what I need the result
for each curve i need that data of that curve who date is max in that curve group
so say for 1001 there are two date 1/1/2001 and 1/1/2002
I need the data of curve 1001 with date 1/1/2002
Oracle should have some alternative solution for this....
If i have to use subquery I do have subquery
select a.curveid, b.curvename from curve a group by curveid having curvedate = (select max(curvedate) from curve where a.curveid=b.curveid group by curveid );
I don't want to use that ,,,
I want to solve my probelm using having and group/....
Main purpose of having is to filter the records from group result so IT SHOULD DO THAT WHY ORACLE GIVE ORA ERROR FOR
group by curve_id having curve_date=max(curve_date)
Creators of oracle please reply -
Use of Where and having clause
Hi all,
I always have a doubt about use of HAVING and WHERE clause,
suppose I have table T1 with only one column C1
CREATE TABLE T1
(C1 VARCHAR2(1) );
which having data by following INSERT scripts
INSERT INTO T1 VALUES('A');
INSERT INTO T1 VALUES('B');
INSERT INTO T1 VALUES('C');
INSERT INTO T1 VALUES('A');
INSERT INTO T1 VALUES('B');
INSERT INTO T1 VALUES('A');
Now I want result as follows
C1 ==== COUNT(C1)
==============
B ===== 2
A ===== 3
So out of query 1 and 2 which approach is right ?
1) SELECT C1,COUNT(C1) FROM T1
WHERE C1<>'C'
GROUP BY C1
ORDER BY C1 DESC;
2) SELECT C1,COUNT(C1) FROM T1
GROUP BY C1
HAVING C1<>'C'
ORDER BY C1 DESC;
Edited by: user13306874 on Jun 21, 2010 2:36 AMIn SQL, it's always best to filter data at the earliest moment possible.
In your example the WHERE clause would be that moment:
SQL> explain plan for
2 select c1,count(c1)
3 from t1
4 where c1 != 'C'
5 group by c1
6* order by c1 desc;
Explained.
SQL> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
Plan hash value: 3946799371
| Id | Operation | Name | Rows | Bytes |
| 0 | SELECT STATEMENT | | 5 | 10 |
| 1 | SORT GROUP BY | | 5 | 10 |
|* 2 | TABLE ACCESS FULL| T1 | 5 | 10 |
Predicate Information (identified by operation id):
2 - filter("C1"!='C')
18 rows selected.
SQL>As you can see the filter is applied during the scan of T1.
Whereas in the HAVING case:
SQL> explain plan for
2 select c1,count(c1)
3 from t1
4 group by c1
5 having c1 != 'C'
6* order by c1 desc;
Explained.
SQL> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
Plan hash value: 3146800528
| Id | Operation | Name | Rows | Bytes |
| 0 | SELECT STATEMENT | | 6 | 12 |
|* 1 | FILTER | | | |
| 2 | SORT GROUP BY | | 6 | 12 |
| 3 | TABLE ACCESS FULL| T1 | 6 | 12 |
Predicate Information (identified by operation id):
1 - filter("C1"!='C')
18 rows selected.
SQL>The scan is done after all groups have been computed: one of which was computed in vain, since it will be filtered away due to the HAVING clause.
In general I would use as a guideline: if you are not using aggregate functions in your HAVING clause predicate, then move that predicate to the WHERE portion of your query.
Edited by: Toon Koppelaars on Jun 21, 2010 11:54 AM -
Dynamic select query with dynamic where condition
Hi all,
I want to use the dynamic select query with dynamic where condition. For that I used the below code but I am getting dump when using this code.
Please advice, if there is any other way to achieve this requirement.
Thanks,
Sanket Sethi
Code***************
PARAMETERS: p_tabnam TYPE tabname,
p_selfl1 TYPE edpline,
p_value TYPE edpline,
p_where1 TYPE edpline .
DATA: lt_where TYPE TABLE OF edpline,
lt_sel_list TYPE TABLE OF edpline,
l_wa_name TYPE string,
ls_where TYPE edpline,
l_having TYPE string,
dref TYPE REF TO data,
itab_type TYPE REF TO cl_abap_tabledescr,
struct_type TYPE REF TO cl_abap_structdescr,
elem_type TYPE REF TO cl_abap_elemdescr,
comp_tab TYPE cl_abap_structdescr=>component_table,
comp_fld TYPE cl_abap_structdescr=>component.
TYPES: f_count TYPE i.
FIELD-SYMBOLS : <lt_outtab> TYPE ANY TABLE,
* <ls_outtab> TYPE ANY,
<l_fld> TYPE ANY.
struct_type ?= cl_abap_typedescr=>describe_by_name( p_tabnam ).
elem_type ?= cl_abap_elemdescr=>describe_by_name( 'F_COUNT' ).
comp_tab = struct_type->get_components( ).
comp_fld-name = 'F_COUNT'.
comp_fld-type = elem_type.
APPEND comp_fld TO comp_tab.
struct_type = cl_abap_structdescr=>create( comp_tab ).
itab_type = cl_abap_tabledescr=>create( struct_type ).
l_wa_name = 'l_WA'.
CREATE DATA dref TYPE HANDLE itab_type.
ASSIGN dref->* TO <lt_outtab>.
*CREATE DATA dref TYPE HANDLE struct_type.
*ASSIGN dref->* TO <ls_outtab>.
* Creation of the selection fields
APPEND p_selfl1 TO lt_sel_list.
APPEND 'COUNT(*) AS F_COUNT' TO lt_sel_list.
** Creation of the "where" clause
*CONCATENATE p_selfl1 '= '' p_value ''.'
* INTO ls_where
* SEPARATED BY space.
*APPEND ls_where TO lt_where.
* Creation of the "where" clause
APPEND p_where1 TO lt_where.
* Creation of the "having" clause
l_having = 'count(*) >= 1'.
* THE dynamic select
SELECT (lt_sel_list)
FROM (p_tabnam)
INTO CORRESPONDING FIELDS OF TABLE <lt_outtab>.
* WHERE (lt_where).Hi Sanket,
The above given logic of mine works for you, put the code in the If condition and try-
just like below:
IF NOT P_EBELN IS INITIAL.
lt_where = '& = ''&'' '.
REPLACE '&' WITH p_ebeln INTO lt_where.
REPLACE '&' WITH field_value INTO lt_where.
SELECT (lt_sel_list) INTO CORRESPONDING FIELDS OF TABLE <lt_outtab>
FROM (p_tabnam)
WHERE (lt_where).
ENDIF.
thanks\
Mahesh
Maybe you are looking for
-
Can I share HP PSC 1610 All-In-One series printer through Bonjour?
I have an iBook G4, and a Mac Mini (10.4.11- Tiger) with a HP PSC 1610 All In One series printer connected to it by USB. On my iBook G4, the printer comes up under Shared Printers in the Printer Setup Utility but when I click on it, and press Show In
-
Family members dependent scenario
Hi all i have got a problem. The problem is related to IT 21. Actually one of our application fetches the family dependents data from the IT21. We need that if a daughter gets married there should be some meachanism or some flag ..that can tell the s
-
Quantity Proration in case of Price change for a Disconnected Installation
Hi Experts, As we know if any installation is disconnected then interpolation or Extrapolation of MR will result to Zero consumption , Logically it is correct because after disconnection you can not have consumption . Because of this if Price change
-
Noob on overclocking here,,,,,,,, hello?
Finally decided to give the overclocking a try. Just installed a Thermaltake Volcano 11 on my Build #2. I am going to attempt to crank it up a little. Now I understand this much, I should give the thermal paste (Artic Silver 5) a while to set in, so
-
How can convert HTML file into xml file?
Hi, I am receving one HTML file as an input and i want to convert that receiving(html file) into .xml file.Is there any converter (tools)to do this.Pls if any give me the details with regard. Regards, mahesh.