Why below MERGE sql statement is throwing error on 10g?
Version: Ora 10g R2
Why below MERGE sql statement is throwing error on 10g?
SQL> merge into sess_stats
using
select a.name, b.value from v$statname a, v$sesstat b where a.statistic#=b.statistic# and b.sid=:sid and (a.name like '%ga %' or a.name like '%direct temp%')
) curr_stats
on (sess_stats.name=curr_stats.name)
when matched then
update set diff=curr_stats.value-sess_stats.value, value=curr_stats.value
when not matched then
insert (name, value, diff) values (curr_stats.name, curr_stats.value, null) 2 3 4 5 6 7 8 SQL> SP2-0734: unknown command beginning "on (sess_s..." - rest of line ignored.
SQL> SP2-0734: unknown command beginning "when match..." - rest of line ignored.
SQL> 2 3
First of all, thank you all for your feedback!
first, I try remove the blank lines at those two places ( before curr_stats and after on) and it works.
then, again I try to set sqlblanklines on, and it works as well!
Edited by: PhoenixBai on Nov 10, 2009 10:54 PM
Similar Messages
-
Identifying statement which throws error
Hi Experts,
I have an ad-hoc query having multiple DML statements. Is is possible to get the command or say statement which throws error using try .. catch block?
Thanks,
Naveen
Naveen J VSELECT
ERROR_NUMBER() AS ErrorNumber,
ERROR_SEVERITY() AS ErrorSeverity,
ERROR_STATE() AS ErrorState,
ERROR_PROCEDURE() AS ErrorProcedure,
ERROR_LINE() AS ErrorLine,
ERROR_MESSAGE() AS ErrorMessage;
Best Regards,Uri Dimant SQL Server MVP,
http://sqlblog.com/blogs/uri_dimant/
MS SQL optimization: MS SQL Development and Optimization
MS SQL Consulting:
Large scale of database and data cleansing
Remote DBA Services:
Improves MS SQL Database Performance
SQL Server Integration Services:
Business Intelligence -
Can I write merge SQL statement having count(*)?
Hi this is a followup question of my previous post. I tried to use a merge SQL statement to solve my problem but now I bump into another problem.
Now I have a table where the field I need to update is a partial PK
when using a merge SQL statement, I have to put a where clause that check if count(*) = 1 because of the PK constraint
Where can I put the count(*) = 1 clause?
Here are the details:
I have two tables TA and TB, where TA contains the fields ID, FULLNAME, TYPE and TB contains the fields ID, FIRSTNAME
I want to update the firstnames in TB to be the firstnames from TA where TB.ID = TA.ID and TA.TYPE = 'ABC'
{ID, FIRSTNAME} are PKs but for the same ID, there can be more than 1 firstname.
e.g.
TA
ID | FULLNAME | TYPE
1 Caroline T ABC
2 Mary C DEF
3 Peter J ABC
TB
ID | FIRSTNAME
1 Caroline
1 Carol
1 C,
3 Peter
I need to update TB with the new firstnames from TA where type is 'ABC' but only for those fields that have count(TB.ID) = 1
when I try to run this SQL statement
merge into TB B using TA A
on (A.ID = B.ID and A.TYPE = 'ABC')
when matched then update set B.FIRSTNAME = substr(A.FULLNAME, 1, instr(A.FULLNAME, ',') - 1)
I got this error SQL Error: ORA-00001: unique constraint (TEST.PK_TB) violated
which I believe is because I updated those fields say ID = 1, all with 'Caroline'
that means I will have to add a clause having count(TB.ID) = 1
How would you do it?
Server is Oracle 11g
Thank you!Hi,
One way is to join ta and tb in the USING clause, and eliminate the duplicates there.
MERGE INTO tb dst
USING (
SELECT ta.id
, REGEXP_SUBSTR ( MIN (ta.fullname)
, '^[^,]*'
) AS firstname
FROM ta
JOIN tb ON ta.id = tb.id
WHERE ta.type = 'ABC'
GROUP BY ta.id
HAVING COUNT (*) = 1
) src
ON (scr.id = dst.id)
WHEN MATCHED THEN UPDATE
SET dst.firstname = src.firstname
;If you'd care to post CREATE TABLE and INSERT statements for your sample data, then I could test this.
I used REGEXP_SUBST instead of SUBSTR and INSTR to find the firstname, because I find it a little cleaner, and becuase it returns something even when there is no ',' in fullname, which I'm guessing is what you really want. (None of the fullnames in your sample data have ','s.) You could use SUBSTR and INSTR instead. -
Can I capture the SQL statement cuasing an error?
I have an error log that capures SQLCODE & SQLERRM.
Can I also capture the actual SQL statement causing the error?there is also format call stack, format error stack and format error backtrace.
/* Formatted on 6/21/2011 3:45:40 PM (QP5 v5.149.1003.31008) */
BEGIN
FOR c IN (SELECT TO_NUMBER ('hey Im not a number') FROM DUAL)
LOOP
NULL;
END LOOP;
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.PUT_LINE ('SQLCODE :' || SQLCODE);
DBMS_OUTPUT.PUT_LINE ('SQLERRM :' || SQLERRM);
DBMS_OUTPUT.
put_line (
'call stack...' || CHR (10) || DBMS_UTILITY.FORMAT_call_STACK ());
DBMS_OUTPUT.
put_line (
'Error_Stack...' || CHR (10) || DBMS_UTILITY.FORMAT_ERROR_STACK ());
DBMS_OUTPUT.
put_line (
'Error_Backtrace...'
|| CHR (10)
|| DBMS_UTILITY.FORMAT_ERROR_BACKTRACE ());
DBMS_OUTPUT.PUT_LINE ('----------');
RAISE;
END;
SQLCODE :-1722
SQLERRM :ORA-01722: invalid number
call stack...
----- PL/SQL Call Stack -----
object line object
handle number name
c0000002a56b4248 11 anonymous block
Error_Stack...
ORA-01722: invalid number
Error_Backtrace...
ORA-06512: at line 2
---------- -
Why is the statement "if (fn_vec.length == 0)" throwing error "RangeError: Error #1125: The index 0 is out of range 0."?
fn_vec is a Vector.<Function>, and it's not null. It's length is in fact zero.
This makes no sense.Hi yu.wei.qian.07,
the problem with the second block of code is that you are
enumerating through the children of the canvas using their index
number. The problem with this is that you are removing children
from the canvas. When you remove a child from a parent object the
index is recalculated and ultimately the number of children for
that parent object is reduced by 1. Since you are starting at zero
and going forward through the loop index you are reaching the last
child index about half way through the loop. A way that would
probably work to fix this would be to loop backwards through the
children (ie start at the last index and loop back to index 0).
I hope this helps. -
Why has the sql statement been extucted two times in shell script?
I tried to test rac load balance using the following shell script on suse 10 + oracle 10g rac.
oracle@SZDB:~> more load_balance.sh
#!/bin/bash
for i in {1..20}
do
echo $i
sqlplus -S system/oracle@ORA10G <<EOF
select instance_name from v\$instance;
EOF
sleep 1
done
exit 0After execute shell script, I got the follow result.
oracle@SZDB:~> ./load_balance.sh
1
INSTANCE_NAME
ora10g2
INSTANCE_NAME
ora10g2
2
INSTANCE_NAME
ora10g1
INSTANCE_NAME
ora10g1
3
INSTANCE_NAME
ora10g1
INSTANCE_NAME
ora10g1Seem the sql statement has been executed two times in each loop. If you feel free please help to have a look. Thanks in advance.
RobinsonYou can end a SQL command in one of three ways:
* with a semicolon (;)
* with a slash (/) on a line by itself
* with a blank line
A semicolon (;) tells SQL*Plus that you want to run the current command that was entered. SQL*Plus processes the command and also stores the command in the SQL buffer.
A blank line in a SQL statement or script tells SQL*Plus that you have finished entering the command, but do not want to run it yet, but it's stored the command on SQL Buffer.
A slash (/) on a line by itself tells SQL*Plus that you wish to run the command stored on SQL buffer. -
ORA-06502: PL/SQL: numeric or value error in 10g
We were using a Function in Oracle 9i which uses max()
function against CHAR field.
It was working fine until now. We are moved database
from 9i to 10g.
Now i am getting "ORA-06502: PL/SQL: numeric or value error:
character string buffer too small"
I have created simple function and tested. Actual Char field
size is 10. In that function we also declared the variable size of 20 to store the value.
But when we run the function in Oracle 10g we give the variable size char(4000
) then it works.
we have many functions like this we are confusing whether these functions are working or not in 10g
why this happening please give a solution
Regards
ShijuTry this. It is the Oracle recommended workaround and it worked for us.
ALTER SYSTEM SET blank_trimming=TRUE SCOPE=SPFILE
STOP AND START THE instance.
Good Luck! -
SQL Developer Tool Throws error on "/"
I am executing a script which is creating a view using sql developer. The script at the end has a "/" but before the / there is a blank line on top. and another view does not have a blank line but has a few spaces before "/" both the cases the sql developer throws compilation error.
there are other parts of the code which does have lot of balnk lines above eg in procedure & trgger (not views) and they compile perfect.
When i run the same script in sql plus or command line sql plus both have no issues. Its only the tool which is behaving like this.
Is this a known issue?Example 1:
CREATE OR REPLACE VIEW x AS
SELECT abc from A where (abc=3) AND (xyz,6)
plz note two blank likes above /
Example 2:
CREATE OR REPLACE VIEW x AS
SELECT abc from A where (abc=3) AND (xyz,6)
plz note few spaces before the /
error says command not ended properly.
this works in sql plus -
Why would this select statement give an error?
*LOOKUP Z_HELPER
*DIM TGT1 : ACCOUNT="AA_1070100"
*DIM CATEGORY="ACTUAL"
*DIM TIME="2011.JAN"
*ENDLOOKUP
*SELECT(%TGTDEST2%, "[ID]", TARGETDESTINATION, "[UNIQUEIDENTIFIER]"=LOOKUP(TGT))
UniqueIdentifier is a property of Targetdestination dimension. Here is the error its giving:
Validation status of executable file: Failed
- Unclosed quotation mark after the character string '=LOOKUP(TGT'. in:select [ID] from mbrTARGETDESTINATION where [UNIQUEIDENTIFIER]"=LOOKUP(TGT
Validation status of syntax: Failed
- Invalid syntax found; see statements in redNilanjan, I changed TGT to TGT1, still same thing. Here is the big picture outcome I am trying to achieve.
Reporting App
Entity Costcenter Shipto Time Category Account Signed data
ABC CO1 USA 2011.jan Actual ACT123 200
So data is coming in like this, the business wants to set up rules such as.....when Costcenter is CO1 AND Shipto is USA AND Entity is ABC....Change the shipto from USA to INDIA. These rules have to be able to be updated by a business user, So I cant hardcode these rules. My manager doesnt want to use Stored procedures, so here is what I did....
Z_Helper App(Non reporting App)
Entity Costcenter Shipto signeddata (other required dimensions are just dummy values)
ABC CO1 USA 9
Now how does 9 get linked to INDIA? I created a new dimension called TARGETDESTINATION. it has ID(which is nothing but shipto country values), and a property called UNIQUEIDENTIFIER. Unique Identifier basically just assigned a unique value to that shiptocountry member row.
So now I need to write a script logic in reporting app that will look up signed data of 9 in this example, and I was thinking use a select statement to pull INDIA from TARGETDESTINATION dimension.
Let me know if you have any suggestions. thanks. -
Report -Error in SQL Statement
Hi to All,
Whe I ran the report on ODS its giving the following error.
Error Error in SQL Statement:DBIF_RSQL_INVALID-RSQL
Error Error When generating the SQL statement
Error reading the data of Infoprovider ZABCXX
Abort system error in Program SAPLRRK0 and form RSRDR;SRRK0F30-01
Note:ZABCXX is a Multiprovider
Then I identified data type is mismatched for 4 characteristics in ODS , I have changed the data type from Date to Char then deleted the data from ODS and reloaded the six Init packages with different selections.
After reloading I ran the report still same error its showing.
Is any bug in stadard program?
Pls can anyody throw some light on my problem.
Thanks,
Sha.Hi,
Try using transaction code ListCube and see if you are able to see some entries in BW system itself.
Also in RSRT -> Query -> Environment -> Delete old abaps
Also in RSRT -> Query -> Environment -> Generate Queries
And let us know the outoput .
Hope that helps.
Regards
Mr Kapadia
Assigning points is the way to say thanks in SDN. -
sir i am wrintng below an sql statement which i am using in jdbc program ..i am geetin strings date and city from users..plzz tell me how to remove the error...
ResultSet rs=stmt.executeQuery("SELECT * FROM '"+city+"' WHERE DAT='"+user+"'");
thnks in advance
NikunjIf city is the variable which holds the table name, then it must be,
"SELECT * FROM "+city+" WHERE DAT = ";
If dat is a date/time field in the table, then,
"SELECT * FROM "+city+" WHERE DAT = #"+user+"#";
If dat is a text type,
"SELECT * FROM "+city+" WHERE DAT = '"+user+"'";
This holds good for MS-Access, I think you are working on MS-Access.
Sudha -
Adding a field to an sql statement in Oracle Reports error ORA-00933
We have been requested to add a field that already exists in the table referred to by the sql statement in Oracle Reports Builder. The report was set up by a consultant about 3 yrs ago and we don't really have much skill in this area. What is happening when I try to modify the SQL statement, either adding a field or deleting a field to the SELECT statement, causes an error message preventing the statement from being saved. The only way out of the error message is to click Cancel. The error message is
ORA-00933:SQL command not properly ended
ORDER BY Program ==> NAME
Even adding or deleting a space anywhere in the SQL statement causes the error (not adding any new fields). A coworker found that if we comment out the ORDER BY, the statement will accept the new field in the SELECT section, however then we lose the order by functionality. I would like to add one additional field before the FROM. Not sure if any additional data are needed. Thank you.
SELECT p.person_uid PIDM_KEY, p.id_number ID,
p.full_name_lfmi name,
p.BIRTH_DATE, p.GENDER Sex,
Decode(a.residency,'D',p.Primary_ethnicity,'F') Ethn,
a.academic_period TERM,
CASE WHEN :p_group_by = 'PROGRAM' THEN a.program
ELSE ' '
END AS Program,
a.COLLEGE, a.degree, a.major, ' ' rule,
a.STUDENT_POPULATION,a.STUDENT_LEVEL, a.application_status Status, a.application_status_date app_sts_dte,
ad.decision_date1 Last_Dec_Date,
ad.decision1||' '||ad.decision2||' '|| ad.decision3||' '|| ad.decision4||' '|| ad.decision5 Decisions,
/* Deposit Date uses the last term entered in :p_term parameter string */
(SELECT MAX(deposit_effective_date) FROM usf_as_deposit WHERE account_uid = a.person_uid &term_clause group by account_uid) AS "DEPOSIT DATE",
ph.phone as PHONE,
CASE WHEN PS.FIRST_CONTACT IN ('NET','PAP','COM','COP') THEN PS.First_Contact
ELSE CASE WHEN ps.latest_contact IN ('NET','PAP','COM','COP') THEN PS.Latest_Contact
ELSE ' '
END
END AS FIRST_CONTACT,
DECODE(:p_address,'Y',REPLACE(adr.street1||' '||adr.street2||' '||adr.street3||' '||adr.city||','||adr.state||' '||adr.nation||' '||adr.zip,' ',' '),' ') as address, adr.nation, adr.state,
goremal_email_address email, a.residency, a.application_date, p.primary_ethnicity, c.cohort
FROM MST_ADMISSIONS_APPLICATION A,
MST_PERSON p,mst_pre_student PS, Admissions_Cohort c, usf_v_phone_pr_ma ph,
MST_admissions_decision_slot AD, usf_v_email, usf_v_address_dr_lr_ma_pr adr
WHERE a.PERSON_UID = p.person_uid
AND a.curriculum_priority = 1
AND a.person_uid = ps.person_uid
AND a.person_uid = ad.person_Uid(+)
AND a.person_uid = goremal_pidm(+)
AND a.person_uid = adr.pidm(+)
AND a.person_uid = ph.pidm(+)
AND ph.rnum(+) = 1
AND a.person_uid = c.person_uid(+)
AND a.academic_period = c.academic_period(+)
&Where_Clause
/* TAKE OUT FOLLOWING LINE AFTER DATA IS CLEANED UP */
AND NOT(p.id_number = '00000000' OR SUBSTR(p.id_number,1,1) = 'B' OR UPPER(p.full_name_lfmi) LIKE '%TESTING%')
AND a.application_status_date >= NVL(:p_as_of_date,sysdate-8000)
AND a.academic_period = ad.academic_period(+)
AND a.application_number = ad.application_number(+)
AND a.degree <> 'ND' /* AND a.college <> 'LW' -- Does not need non-degree and law students */
&Cohort_Clause
ORDER BY Program &ORDER_CLAUSEHi Denis,
I tried your suggestion. The good thing is that adding the comma allowed me to be able to add a.campus to the select statement, unfortunately, another error message happened.
ORA-00936: missing expression SELECT p . person_uid PIDM_KEY ,
p . id_number , p . full_name_lfmi name , p . BIRTH_DATE , p . GENDER Sex ,
Decode ( a . residency , 'D' , p . Primary_Ethnicity , 'F' ) Ethn , a . academic_period TERM ,
CASE WHEN : P_group_by = 'PROGRAM THEN a I started over and tried only putting in the comma and get the same message even though I didn't add campus. After that, removed the comma which led to the ORA-00933 error message. So once again, I had to close the file without saving, in order for the report to run at all. -
Getting time_out Error in report bcos of SQL Statement!
Hi Experts,
I am getting Time_out error in my big program because of Select statement.I have checked in SQL Trace AND fuond the message
"SQL0104N An unexpected token "vakey" was found following "umh
kschl". Expected tokens may include: ",". SQLSTATE=42601"
I have given the following code and SQL statement where the error is getting occured.Please help.
TYPES: BEGIN OF ty_vakey1,
vakey TYPE vakey,
END OF ty_vakey1,
ty_t_vakey1 TYPE HASHED TABLE OF ty_vakey1 WITH UNIQUE KEY vakey.
DATA: ih_vakey1 TYPE ty_t_vakey1,
wa_vakey1 TYPE ty_vakey1,
wa_vakey TYPE ty_vakey.
LOOP AT i_vakey INTO wa_vakey.
wa_vakey1-vakey = wa_vakey-vakey.
COLLECT wa_vakey1 INTO ih_vakey1.
CLEAR wa_vakey1.
ENDLOOP.
IF ih_vakey1 IS NOT INITIAL.
Here it is required to select the Key field and so cannot be used in Where condition
SELECT knumh "Condition record number
kschl "Pricing conditions
vakey "Variable Key
datab "Valid-From Date
datbi "Valid To Date
FROM konh
INTO TABLE i_konh
FOR ALL ENTRIES IN ih_vakey1
WHERE vakey EQ ih_vakey1-vakey . "#EC CI_NOFIELD
Here #EC CI_NOFIELD is used because the key field of the table konh ( ie knumh)
is to be selected and so is not used in the WHERE condition above
IF sy-subrc NE c_0.
No data found for specified criteria
MESSAGE i036.
LEAVE LIST-PROCESSING.
ENDIF.
Thanks&Regards,
SarkarCheck if i_konh definition matches the fields in the SELECT statement.
Also, since you're not using the primary key when selecting from KONH table, such program by design is going to run forever and may time out eventually. Usually KONH is a very large table. Not sure what's the purpose of this program, but I'm pretty sure there must be some other way to program this. There are actually some standard FMs that read the conditions.
A secondary index might help, but only as a last resort. -
Using 'NOT IN' Within a SQL Statement
Does anyone know why the following SQL statement does not return any values? The problem is with the SELECT statement within the 'NOT IN' clause. When explicitly typing in the part_ids returned from the select statement, everything works as expected.
Thanks for any help.
SELECT Distinct Part_Id, Trans_Date
FROM Invctrl
WHERE Trans_Type = 0
AND Trans_Date BETWEEN To_Date( '1-Mar-2006 00:00:00', 'dd-mon-yyyy hh24:mi:ss' )
AND To_Date( '31-Jan-2007 23:59:59', 'dd-mon-yyyy hh24:mi:ss' )
AND Part_Id NOT IN (SELECT part_Id From InvCtrl WHERE Trans_Date < To_Date( '1-Mar-2006 00:00:00', 'dd-mon-yyyy hh24:mi:ss'))'NOT IN' should be avoided where ever we can.
Change your query to 'IN' clause as below and it should work.
SELECT DISTINCT part_id, trans_date
FROM invctrl
WHERE trans_type = 0
AND trans_date BETWEEN TO_DATE ('1-Mar-2006 00:00:00',
'dd-mon-yyyy hh24:mi:ss'
AND TO_DATE ('31-Jan-2007 23:59:59',
'dd-mon-yyyy hh24:mi:ss'
AND part_id IN (
SELECT part_id
FROM invctrl
WHERE trans_date BETWEEN TO_DATE ('1-Mar-2006 00:00:00',
'dd-mon-yyyy hh24:mi:ss'
AND TO_DATE ('31-Jan-2007 23:59:59',
'dd-mon-yyyy hh24:mi:ss'
MINUS
SELECT part_id
FROM invctrl
WHERE trans_date <
TO_DATE ('1-Mar-2006 00:00:00',
'dd-mon-yyyy hh24:mi:ss'
[pre] -
How to join multiple SQL statements?
I'm try to combine four of the following SQL statements as one, and I basically want to group by the new combined sql statement by suspension
Using: Oracle 10g
Here's my sql statements/what I've tried but doesn't seem to work:
select *
from
--NBA
select
decode (t.league_id, 1 , 'NBA') as League,
t.moniker as First,
t.Last_name as Last,
(t.To_Team_Name || ' ' || To_Team_Nickname) as Team,
count(*) Suspensions
from customer_data.cd_bk_trans t,
customer_data.cd_bk_roster r
where t.player_id = r.player_id
and t.trans_type_id in (12,13,14)
and r.status = 'Y'
and r.league_id = 01
group by t.league_id,t.last_name, t.moniker, t.to_team_name,t.to_team_nickname
order by Suspensions desc
union
--MLB
select
decode (t.league_id, 7 , 'MLB') as League,
t.moniker as First,
t.Last_name as Last,
(t.from_Team_Name || ' ' || from_Team_Nickname)as Team,
count(*) Suspensions
from customer_data.cd_baseball_trans t,
customer_data.cd_baseball_roster r
where t.player_id = r.player_id
and t.comments like '%Susp%'
and r.status = 'Y'
and r.league_id = 07
group by t.league_id,t.last_name, t.moniker, t.from_team_name,t.from_team_nickname
order by Suspensions desc
union
--NHL
select
decode (r.team_id,18, 'NHL') as League,
t.fn as First,
t.ln as Last,
(t.from_Team_Name || ' ' || from_Team_Nickname)as Team,
count(*) Suspensions
from customer_data.cd_nhl_trans t,
customer_data.cd_nhl_roster r
where t.player_id = r.player_id
and t.trans_type in (10,11,12)
and r.status = 'Y'
and r.league_id = 18
group by r.league_id, t.ln, t.fn, t.from_team_name,t.from_team_nickname
order by Suspensions desc
union
--NFL
select
decode (t.league_id, 8, 'NFL') as League,
t.moniker as First,
t.last_name as Last,
(t.from_Team_Name || ' ' || from_Team_Nickname)as Team,
count(*) Suspensions
from customer_data.cd_football_trans t,
customer_data.cd_football_roster r
where t.player_id = r.player_id
and t.trans_type_id in (24,25)
and r.status = 'Y'
and r.league_id = 8
group by t.league_id, t.last_name, t.moniker, t.from_team_name,t.from_team_nickname
order by Suspensions desc
Order by Suspensions descHi,
Remove the ORDER BY clause in all the queries expcept lastone. Then it will work.
You can have the ORDER BY clause in the last query of the inline view. Otherwise it will give the error.
Run the query given below
SELECT *
FROM (
--NBA
SELECT decode(t.league_id, 1, 'NBA') AS league,
t.moniker AS FIRST,
t.last_name AS LAST,
(t.to_team_name || ' ' || to_team_nickname) AS team,
COUNT(*) suspensions
FROM customer_data.cd_bk_trans t, customer_data.cd_bk_roster r
WHERE t.player_id = r.player_id
AND t.trans_type_id IN (12, 13, 14)
AND r.status = 'Y'
AND r.league_id = 01
GROUP BY t.league_id,
t.last_name,
t.moniker,
t.to_team_name,
t.to_team_nickname
UNION
--MLB
SELECT decode(t.league_id, 7, 'MLB') AS league,
t.moniker AS FIRST,
t.last_name AS LAST,
(t.from_team_name || ' ' || from_team_nickname) AS team,
COUNT(*) suspensions
FROM customer_data.cd_baseball_trans t,
customer_data.cd_baseball_roster r
WHERE t.player_id = r.player_id
AND t.comments LIKE '%Susp%'
AND r.status = 'Y'
AND r.league_id = 07
GROUP BY t.league_id,
t.last_name,
t.moniker,
t.from_team_name,
t.from_team_nickname
UNION
--NHL
SELECT decode(r.team_id, 18, 'NHL') AS league,
t.fn AS FIRST,
t.ln AS LAST,
(t.from_team_name || ' ' || from_team_nickname) AS team,
COUNT(*) suspensions
FROM customer_data.cd_nhl_trans t, customer_data.cd_nhl_roster r
WHERE t.player_id = r.player_id
AND t.trans_type IN (10, 11, 12)
AND r.status = 'Y'
AND r.league_id = 18
GROUP BY r.league_id,
t.ln,
t.fn,
t.from_team_name,
t.from_team_nickname
UNION
--NFL
SELECT decode(t.league_id, 8, 'NFL') AS league,
t.moniker AS FIRST,
t.last_name AS LAST,
(t.from_team_name || ' ' || from_team_nickname) AS team,
COUNT(*) suspensions
FROM customer_data.cd_football_trans t,
customer_data.cd_football_roster r
WHERE t.player_id = r.player_id
AND t.trans_type_id IN (24, 25)
AND r.status = 'Y'
AND r.league_id = 8
GROUP BY t.league_id,
t.last_name,
t.moniker,
t.from_team_name,
t.from_team_nickname
ORDER BY suspensions DESC)
ORDER BY suspensions DESC
Maybe you are looking for
-
Retrieve data from a stored procedure using powerpivot
Hi there. I'm new to SQL and would like to import the below stored procedure to PowerPivot. PowerPivot says the statement is valid, but fails to import the stored procedure and returns this error "OLE DB or ODBC error: Changed database context to 'Si
-
Is there any collective way to have Lightroom 5 find lost files?
Though I have tried to move folders and files only with Lightroom, I note that a good number of my images shown in thumbnails in Library cannot be opened because Lightroom 5 cannot find the files. I assume I have moved files among drives accidentall
-
Create a report in a popup (validation needed in back bean before popup)
Hi all, I am very new to JDev and ADF, I am struggling to generate a report in a popup through the back bean, some validation is needed in the back bean before the popup. When creating the popup window, the url of the popup will be the URL of a servl
-
Standard message type to transfer data for transportation planning
Hi, We would like to develop a interface that would transfer the following data from SAP to another system (called Vista). "(Past) Receivings and requirements shall be considered in the transportation planning. Transfer the requirement information fr
-
Can I use I-Web with other hosting service? (ie not .Mac?)
HI, I would like to know if I HAVE to subscribe to .Mac in order to use I-web or can I use my other hosting service to build a snaps website. It seems that one is bound to sue .Mac, but was not sure if this is the case. Rebecca