Please help on this query
Hello everyone,
i am pretty new and still learning SQL for my work.
i have a query to pull all the data greater than 5,000,000 as below which worked sucessfully
select a.bf_fund_cd fund, a.bf_bdob_cd object, b.lev5, b.bf_orgn_cd,sum(a.data) data
from cp_o_pbuser.bf_data a
inner join cp_o_pbuser.bf_orgn_cnsl_tbl b
on a.bf_orgn_cd = b.bf_orgn_cd
WHERE a.bf_tm_perd_cd in (select bf_tm_perd_chld_cd from cp_o_pbuser.bf_tm_perd_cnsl_tbl where bf_tm_perd_select_cd='FINALTOT')
and a.bf_bdob_cd in ('R_9001')
having sum(a.data)>5000000
group by a.bf_fund_cd, a.bf_bdob_cd, b.lev5,b.bf_orgn_cd
order by a.bf_bdob_cd, b.lev5
here is the result
SS_26300_1 - Lev5 (everything rollup to this one)
SS_26460_2 - $ 5,000,000 -->bf_orgn_cd (showed)
SS_26461_2 - $6,000,000 -->bf_orgn_cd (showed)
SS_26473_2 - $5,500,000 -->bf_orgn_cd (showed)
SS_26475_2 -$4,000,000 -->bf_orgn_cd (not showed, i want to this record to appear too)
However, according to the new change, i will need to pull out all the data even though they are smaller than 5,000,000 in the
lev5 colunm. ex: there is one record missing in SS_26300_1 with SS_26475_2 in BF_ORGN_CD and the data is 4,000,000 which i need to include in my query.
i really appreciate of your time and help.
Sincerely,
clear example: thank you
SS_21111_1 -Lev5 (dont need to show) ---> less than 5,000000
SS_21112_2 -$1,500,000(dont need to show)
SS_21113_2 -$1,750,000(dont need to show)
SS_26300_1 - Lev5 (everything rollup to this one) greater than 5,000,000 (everything needs to show)
SS_26460_2 - $ 5,000,000 -->bf_orgn_cd (showed)
SS_26461_2 - $6,000,000 -->bf_orgn_cd (showed)
SS_26473_2 - $5,500,000 -->bf_orgn_cd (showed)
SS_26475_2 -$4,000,000(i want to this one to show)
Similar Messages
-
Plz help me this query:
Create a query that displays the employees last name and indicates the amounts of their annual salaries with *. Each * signifies a thousand $'s.
EG. If the salary of an employee with last name king is 2000 then it should appear as follows:
King **
2 (*) for 2 thousand.
Thanks in advanceHi,
I was able to solve this query on my own. For those who might face a problem in future the solutionto it is:
SELECT rpad(last_name, length(last_name) + (salary/1000), '*') AS employee_and_their_salaries
FROM employees;
Thanks -
Please help with this query!
Hi All,
I have this this table:
Term Grade
term_A A
term_A A
term_A B
term_A B
term_B D
term_B F
term_B F
term_C C
How do I display so that it appears this way?
term_A A 2
term_A B 2
term_B D 1
term_B F 2
term_C C 1
Thank you. Appreciate all the help!Please read about [url http://download-uk.oracle.com/docs/cd/B19306_01/server.102/b14200/functions001.htm#sthref962]aggregate functions in the manual.
Regards,
Rob. -
Following is the sql code
SELECT mbr_contr_med_cov_flag,
mbr_contr_rx_cov_flag,
src_mbr_id,
cov_cd_eff_dt,
MIN (
TO_DATE (
SYS_CONNECT_BY_PATH (
DECODE (LEVEL, 1, TO_CHAR (elig_eff_dt), ''),
AS beg_dt,
MAX (elig_term_dt) term_dt
FROM temp_elig_mem
CONNECT BY PRIOR src_mbr_id = src_mbr_id
AND PRIOR elig_term_dt + 1 = elig_eff_dt
GROUP BY mbr_contr_med_cov_flag,
mbr_contr_rx_cov_flag,
src_mbr_id,
cov_cd_eff_dtExplain plan:
PLAN_TABLE_OUTPUT
| Id | Operation | Name | Rows | Bytes | Cost |
| 0 | SELECT STATEMENT | | 311K| 13M| 426 |
| 1 | HASH GROUP BY | | 311K| 13M| 426 |
| 2 | CONNECT BY WITHOUT FILTERING| | | | |
| 3 | TABLE ACCESS FULL | TEMP_ELIG_MEM | 311K| 13M| 411 |
-------------------------------------------------------------------------------Funny part is if I remove a 'PRIOR' from the code it runs faster. I mean the following code with one 'PRIOR' taken out runs faster:
SELECT mbr_contr_med_cov_flag,
mbr_contr_rx_cov_flag,
src_mbr_id,
cov_cd_eff_dt,
MIN (
TO_DATE (
SYS_CONNECT_BY_PATH (
DECODE (LEVEL, 1, TO_CHAR (elig_eff_dt), ''),
AS beg_dt,
MAX (elig_term_dt) term_dt
FROM temp_elig_mem
CONNECT BY PRIOR src_mbr_id = src_mbr_id
AND elig_term_dt + 1 = elig_eff_dt
GROUP BY mbr_contr_med_cov_flag,
mbr_contr_rx_cov_flag,
src_mbr_id,
cov_cd_eff_dtuser2361373 wrote:
The problem may be due to MIN and MAX().Whole query is a mess. Just look at decode. For LEVEL= 1 it returns TO_CHAR(elig_eff_dt). For other levels it returns NULL. Therefore:
SYS_CONNECT_BY_PATH(
DECODE(LEVEL,1,TO_CHAR(elig_eff_dt),''),
)returns TO_CHAR(elig_eff_dt) of LEVEL = 1 followed by bunch of spaces. Then OP converts it back to DATE. In other words, regardless what LEVEL is it returns top level (LEVEL = 1) elig_eff_dt, which is nothing but CONNECT_BY_ROOT elig_eff_dt. So query can be simplified:
SELECT mbr_contr_med_cov_flag,
mbr_contr_rx_cov_flag,
src_mbr_id,
cov_cd_eff_dt,
MIN(CONNECT_BY_ROOT elig_eff_dt) AS beg_dt,
MAX(elig_term_dt) term_dt
FROM temp_elig_mem
CONNECT BY PRIOR src_mbr_id = src_mbr_id
AND PRIOR elig_term_dt + 1 = elig_eff_dt
GROUP BY mbr_contr_med_cov_flag,
mbr_contr_rx_cov_flag,
src_mbr_id,
cov_cd_eff_dt
/Now:
CONNECT BY PRIOR src_mbr_id = src_mbr_id
AND elig_term_dt + 1 = elig_eff_dtIt obviously lacks PRIOR:
CONNECT BY PRIOR src_mbr_id = src_mbr_id
AND PRIOR elig_term_dt + 1 = elig_eff_dtNow, assuming table is relatively big, since there is no START WITH I suspect number of unnecessary rows built by hierarchy is a big part of performance issue. I'd add:
START WITH (src_mbr_id,elig_eff_dt) IN (SELECT src_mbr_id,MIN(elig_eff_dt) FROM temp_elig_mem GROUP BY src_mbr_id)And if all rows in each hierarchy have same mbr_contr_med_cov_flag, mbr_contr_rx_cov_flag, cov_cd_eff_dt:
MAX(elig_term_dt) term_dtis nothing but elig_term_dt from the hierarchy leaf row. Then whole query can be simplified to:
SELECT mbr_contr_med_cov_flag,
mbr_contr_rx_cov_flag,
src_mbr_id,
cov_cd_eff_dt,
CONNECT_BY_ROOT elig_eff_dt AS beg_dt,
elig_term_dt term_dt
WHERE CONNECT_BY_ISLEAF = 1
FROM temp_elig_mem
START WITH (src_mbr_id,elig_eff_dt) IN (SELECT src_mbr_id,MIN(elig_eff_dt) FROM temp_elig_mem GROUP BY src_mbr_id)
CONNECT BY PRIOR src_mbr_id = src_mbr_id
AND PRIOR elig_term_dt + 1 = elig_eff_dt
/SY.
Edited by: Solomon Yakobson on Jan 16, 2012 7:08 PM -
Please need help with this query
Hi !
Please need help with this query:
Needs to show (in cases of more than 1 loan offer) the latest create_date one time.
Meaning, In cases the USER_ID, LOAN_ID, CREATE_DATE are the same need to show only the latest, Thanks!!!
select distinct a.id,
create_date,
a.loanid,
a.rate,
a.pays,
a.gracetime,
a.emailtosend,
d.first_name,
d.last_name,
a.user_id
from CLAL_LOANCALC_DET a,
loan_Calculator b,
bv_user_profile c,
bv_mr_user_profile d
where b.loanid = a.loanid
and c.NET_USER_NO = a.resp_id
and d.user_id = c.user_id
and a.is_partner is null
and a.create_date between
TO_DATE('6/3/2008 01:00:00', 'DD/MM/YY HH24:MI:SS') and
TO_DATE('27/3/2008 23:59:00', 'DD/MM/YY HH24:MI:SS')
order by a.create_datePerhaps something like this...
select id, create_date, loanid, rate, pays, gracetime, emailtosend, first_name, last_name, user_id
from (
select distinct a.id,
create_date,
a.loanid,
a.rate,
a.pays,
a.gracetime,
a.emailtosend,
d.first_name,
d.last_name,
a.user_id,
max(create_date) over (partition by a.user_id, a.loadid) as max_create_date
from CLAL_LOANCALC_DET a,
loan_Calculator b,
bv_user_profile c,
bv_mr_user_profile d
where b.loanid = a.loanid
and c.NET_USER_NO = a.resp_id
and d.user_id = c.user_id
and a.is_partner is null
and a.create_date between
TO_DATE('6/3/2008 01:00:00', 'DD/MM/YY HH24:MI:SS') and
TO_DATE('27/3/2008 23:59:00', 'DD/MM/YY HH24:MI:SS')
where create_date = max_create_date
order by create_date -
I was trying to set Adobe Reader 11 as default PDF viewer on my client PCs, Please help me this. My server is windows 2012 R2 and client PCs are Windows 8.1
Hi Krisis,
I have found a forum where similar query was answered. Hope this helps.
http://www.loginvsi.com/forum/support-v4/857-adobe-reader-xi-not-set-as-default-pdf-viewer -in-server-2012-r2-rds
Regards,
Anoop -
Hi , i have a table of 3000000 rows, and am executing this script
update products set cas_num = trim(cas_num
due to which it is taking 99.2% of UNDO TS ,
I was just exactly thinking the same if i can put it in a simple SQL loop statement and have it commit for like every 10,000 rows.
Could you please help me a better way to to accomplish this simple SQL loop statement?
Thanks
VkCheck your original post. You wouldn't get different replies as the same set of people check here too.
Help on this query ( taking 99% of UNDO TS on 10g ) -
SQL experts please help for a query
I have following table1.
What query can give the result as given below, SQL experts please help on this.
TABLE1
Event DATETIME
in 2/JAN/2010
out 2/JAN/2010
in 13/JAN/2010
out 13/JAN/2010
in 5/JAN/2010
out 5/JAN/2010
RESULT REQUIRED FROM THE SQL QUERY
COL1_IN COL2_OUT
2/JAN/2010 2/JAN/2010
13/JAN/2010 13/JAN/2010
5/JAN/2010 5/JAN/2010I tried to help, but this puzzles me.
Why is this not returning pre-selected set of rows, why it's doing some merge join cartezian ?
SQL> select * from v$version;
BANNER
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Prod
PL/SQL Release 10.2.0.4.0 - Production
CORE 10.2.0.4.0 Production
TNS for Linux: Version 10.2.0.4.0 - Production
NLSRTL Version 10.2.0.4.0 - Production
SQL> select * from table1;
EVENT DATETIME
in 2/JAN/2010
out 2/JAN/2010
in 13/JAN/2010
out 13/JAN/2010
in 5/JAN/2010
out 5/JAN/2010
6 rows selected.
SQL> explain plan for
2 with a as
(select datetime from table1 where event='in'),
b as
(select datetime from table1 where event='out')
select a.datetime COL1_IN ,b.datetime COL2_OUT from a,b ;
Explained.
SQL> set wrap off
SQL> set linesize 200
SQL> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
Plan hash value: 185132177
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 9 | 288 | 8 (0)| 00:00:01 |
| 1 | MERGE JOIN CARTESIAN| | 9 | 288 | 8 (0)| 00:00:01 |
|* 2 | TABLE ACCESS FULL | TABLE1 | 3 | 48 | 3 (0)| 00:00:01 |
| 3 | BUFFER SORT | | 3 | 48 | 5 (0)| 00:00:01 |
|* 4 | TABLE ACCESS FULL | TABLE1 | 3 | 48 | 2 (0)| 00:00:01 |
PLAN_TABLE_OUTPUT
Predicate Information (identified by operation id):
2 - filter("EVENT"='in')
4 - filter("EVENT"='out')
Note
- dynamic sampling used for this statement
21 rows selected.
SQL> with a as
(select datetime from table1 where event='in'),
b as
(select datetime from table1 where event='out')
select a.datetime COL1_IN ,b.datetime COL2_OUT from a,b ;
COL1_IN COL2_OUT
2/JAN/2010 2/JAN/2010
2/JAN/2010 13/JAN/2010
2/JAN/2010 5/JAN/2010
13/JAN/2010 2/JAN/2010
13/JAN/2010 13/JAN/2010
13/JAN/2010 5/JAN/2010
5/JAN/2010 2/JAN/2010
5/JAN/2010 13/JAN/2010
5/JAN/2010 5/JAN/2010
9 rows selected.
SQL> -
search criteria is not working in Responsible Group field in sap crm could you please help me this how to achieve.I have writen code on EH_ONSEARCH .as per below...what changess i need to do..and through partner function and adding the selection params please send the sample .
code. partner funtction - ZRG DATA :
DATA : lv_partner_fct type .
types: begin of ty_resp,
partner type but000-partner,
name_last type but000-name_last,
name_first type but000-name_first,
mc_name1 type but000-mc_name1,
mc_name2 type but000-mc_name2,
end of ty_resp.
DATA: lv_resp_bp type STANDARD TABLE OF ty_resp INITIAL SIZE 0,
lw_resp_bp type ty_resp.
IF lv_attr_name = 'Rgroup'.
lr_entity->get_property_as_value( EXPORTING iv_attr_name = if_crm_srqm_uiu_const=>gc_attr_low
IMPORTING ev_result = lv_low ).
IF lv_low IS INITIAL.
SELECT partner
name_last
name_first
mc_name1
mc_name2
FROM but000 INTO table lv_resp_bp
WHERE mc_name2 = lv_low and bu_group = '0010'.
loop at lv_resp_bp into lw_resp_bp.
lv_low = lw_resp_bp-mc_name2.
lr_query_service2->add_selection_param( iv_attr_name = 'Rgroup'
iv_sign = lv_sign
iv_option = lv_option
iv_low = lv_low
iv_high = lv_high ).
ENDLOOP.
if lv_partner_fct = 'ZRG'.
lr_entity = lr_iterator->get_next( ).
CONTINUE.
ENDIF.
lv_attr_name = 'BU_PARTNER'.
ENDIF.<b>You can acheive this .... first by creating the search help exit ... by creating the maintaince view then using it in the Creation of the search help </b> ...
see the link for attaching the view to the serach help .
<a href="http://">http://www.sapdevelopment.co.uk/dictionary/shelp/shelp_elementary.htm</a>
reward points if it is usefull...
Girish -
When trying to verify the email address, I get the following message. Please help. This email address is already in use or you may already have an Apple ID associated with this email address. Please try again or sign in using your existing Apple ID.
Me too. I try to verify and i get the same message.
I've created 3 alternate e-mail addresses and tried creating new accounts.
Same Result!
This is bullsh!t. How the **** can all 4 of my attempts result in the same freakin error??? -
I just bought a new iPhone and accidentally backed it up with my old iPhone backup, I do not want this. I lost everything on my new phone and I need it back. PLEASE HELP! This includes pictures and texts, etc.
So just to be clear, when you say "just bought" how long ago was that? Is it on this new iPhone that you had pictures, texts, etc that you want? Were you backing up to iCloud or onto iTunes?
This may not help for everything but if you go to iCloud.com and log in, are you able to find your pictures there? -
Every time I sync my Iphone 5c(with ios 8) to Itunes, it 1. deletes all of my purchased music 2. deletes all of my album artwork 3. replaces all of my deleted songs. please help! this is driving me crazy! It syncs 100+ songs, when I only want to sync 1! I'm running Itunes 11.3.1.2
After having experienced similar problems and having it back to work, I have a few suggestions:
- Try to find out if the syncing stops at a particular track or song. That might - out of the blue - have gotten corrupted in one way or another. Since that song will not be on the iPod, iTunes will try over and over to put it on and crash in one way or another;
- reformat the iPod as described in the iTunes 9 crash-thread. It takes time (at first it seems to do nothing, but that is because the green bar is moving with very small steps);
HTH -
Hi Experts,
I have schema which has to be implemented in SAP BI 7.0.Schema contains one Fact Table & three Dimension tables.It is snowflake schema.
Assume Fact table as F & Dimension tables as D1,D2,D3.The Schema is as follows.
F---->D1--->D2---->D3
Now i have created navigation attribute from D1 to D2 & D2 to D3 Then i have created a infocube having facts & D1 attribute.
So when i drag the infoObject from D1 having navigation attributes to D2 & from D2 to D3 iam unable to get D3 information.
Please can any one suggest me how to get D3 level of information in report Or how to accesss the facts & D3 level information .
Please Help on this
Thanks & Regards
Sameer KhanHi Sameer,
Your question is not clear.
Regards,
Sagar -
HT5312 i forgot my secret question, please help me this problem. Thanks
I forgot my secret question, please help me this problem. Thanks
Contact iTunes Customer Service and request assistance
Use this Link > Apple Support iTunes Store Contact
And/or see the More Like This section on the right. -
Trying to update photoshop and repeatedly get error code U44M1P7, can you please help resolve this?
JJMack, Thanks for the info. Let this old man digest it and see if I can put the info into action. I'll give you a feedback. Thanks for your help in this matter. I am not a tech savvy person.
Rueben Rueben D. Olivas Home Ph: 1-671-969-2452
Cell Ph: 1-671-747-2453La Luz Photography
Email: [email protected]/Guam Firehouse Cook: http://guamfirehousecook.blogspot.com/BBQGuam: http://bbqguam.blogspot.com/My Photostream: http://ruebenolivas.megashot.net/photostream
Maybe you are looking for
-
How can you change your security questions?! I got the iphone 5 and i forgot them and it wont let me buy songs!!!!
-
Windows 7 with CS4 and PSD Icons
Hi, I have Windows 7 64bit, Photoshop CS4 and Photoshop 7 (for back-up). I know that Photoshop 7 allowed thumbnail previews on PSD's but that was taken out so CS4 is just a custom icon, but Windows 7 doesn't seem to really get what to do with either
-
My iPhone4 will not come on. When i plug it into the charger, it only says connect to iTunes. When I tried restoring it, it said my iPhone4 could not be restored.
-
Problem when using function module : SO_NEW_DOCUMENT_SEND_API1
hi,all when i use this function module to send external email ,a strange problem has been encountered. After executing this FM,i find that the return parameters SY-SUBRC = 0 . but when i use tcode SCOT to check the email in SAP email box,nothing ha
-
Customize system to use less memory
Hi! I'm a bit disapointed with my macmini. It has been really a hard job work with professional applications such Flash, Dreamweaver, Photoshop, etc. Course that an iMac should be more appropriated, but sometimes you get what you can. I want to work