Clubbing two statements into one in Stored Procedure
I am writing a stored procedure and one of the statement goes like this
IF
LOWER(@in_data_detail_info)
LIKE('%low_price%')
BEGIN
set @out_price_col_desc
=
'Low Price'
end
IF
LOWER(@in_data_detail_info)
LIKE('%low_price%')
BEGIN
set @price_type
=
'low_price'
end
since
IF
LOWER(@in_data_detail_info)
LIKE('%low_price%')
is common, can i club it into one something like this
IF
LOWER(@in_data_detail_info)
LIKE('%low_price%')
BEGIN
set @out_price_col_desc
=
'Low Price'
and @price_type
=
'low_price'
end
it was showing error, can we write something similar to reduce the number of lines.
Hi Syed, Please post the error that you get. A quick glance at the block of code "since" what is that since for?
and in last IF block "set @out_price_col_desc
=
'Low Price'
and @price_type
=
'low_price'
" change it like below.
set @out_price_col_desc = 'Low Price'
set @price_type = 'low_price'
Hope this helps..........
Ione
Similar Messages
-
hi
Can we club two rows of a SQL statement into one , that is some column results from one row and other column result from second row, but the row must remain same .
thanks
imranSQL> with sample as (select 'A' supplier, 1000 total, 0 branch_total from dual
2 union all
3 select 'A' supplier, 0 total, 500 branch_total from dual
4 union all
5 select 'B' supplier, 300 total, 0 branch_total from dual
6 union all
7 select 'B' supplier, 0 total, 120 branch_total from dual)
8 SELECT SUPPLIER , SUM(TOTAL) , SUM(BRANCH_TOTAL) FROM SAMPLE
9 GROUP BY SUPPLIER
10 /
SUPPLIER SUM(TOTAL) SUM(BRANCH_TOTAL)
A 1000 500
B 300 120 -
Hi,
I am working on a report what has 10 datasets derived from 10 different select statements.
Is it possilbe to save those 10 select statements as a macro / stored procedure and then use that macro to generate those dataset in the ssrs report builder ?
AshishSinghalHi AshishSinghal84,
According to your description, you want to write multiple select statements in a procedure, then use the procedure as dataset in the report, right?
According to my knowledge, when we write multiple select statements in a procedure, we have to create relationship between these select statements, otherwise it will only return the first one query's fields. If you are using SSRS 2008 R2, you can use Lookup
function to display these fields from different datasets on one data region control, but the prerequisite is that you must have one common field. For more information about lookup function, please see:
http://msdn.microsoft.com/en-us/library/ee210531.aspx
If all these solution you cannot achieve due to your special condition, the last workaround is to use subreport to display all the fields together.
If you have any more questions, please feel free to ask.
Thanks,
Wendy Fu
Wendy Fu
TechNet Community Support -
HT1449 how do you move all music from two computers into one itunes account?
How do you move all music from two computers into one itunes account?
An "iTunes account" is an online account you use for buying music, like a bank account. An iTunes collection is the media you see when you open iTunes. Which do you mean?
If it is two computers, it would also help to know where these are located. Are they on the same local network? If they are, try Home Sharing (and you have control of both and you aren't just trying to get music fro your computer to your friend's computer in another state). If they are not, you'll have to use an external hard drive or flash drive.
Is this on a PC? Your computer information says Windows but you posted this in the iTunes for Mac forum. -
How to Combine two queries into One
Hi Gurus,
SQL> select * from v$version;
BANNER
Oracle Database 10g Release 10.2.0.4.0 - 64bit Production
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>
I have following two queries. How I can convert these two queries into one with the same result ?
Q1
SELECT id,vdate,vendorname,venddate,vid
FROM VENDOR
WHERE processid=32
AND venddate is null
AND vid in(select vid from view_vid where type='PDX')
AND (id,vdate) not in (select id,vdate from vkfl_is where task_id=55)
AND (id,vdate) in (select id,vidate from market_data where marketed_date is null)
AND id not in (select id from location)
Q2
SELECT id,vdate,vendorname,venddate,vid
FROM VENDOR
WHERE processid=20
AND venddate is null
AND vid in(select vid from view_vid where type='PBX')
AND (id,vdate) not in (select id,vdate from vkfl_is where task_id=40)
AND (id,vdate) in (select id,vidate from market_data where region_date is null)
AND id not in (select id from location)
I can UNION these two queries, but, is there any way I can write a single query with which gives me same result as above two queries?
Any help would be highly appreciated
Thanks in advanceHi,
You can do something like this, which will be more efficient than a UNION:
SELECT id, vdate, vendorname, venddate, vid
FROM vendor
WHERE ( ( -- Conditions that apply only to q1
processid = 32
AND vid IN (SELECT vid FROM view_vid WHERE type = 'PDX')
AND (id,vdate) NOT IN ( SELECT id, vdate
FROM vkfl_is
WHERE task_id = 55
AND (id,vdate) IN ( SELECT id, vidate
FROM market_data
WHERE marketed_date IS NULL
OR ( -- Conditions that apply only to q2
processid = 20
AND vid IN (SELECT vid FROM view_vid WHERE type = 'PBX')
AND (id,vdate) NOT IN ( SELECT id, vdate
FROM vkfl_is
WHERE task_id = 40
AND (id,vdate) IN ( SELECT id, vidate
FROM market_data
WHERE region_date IS NULL
-- The remaining conditions apply to both q1 and q2
AND venddate IS NULL
AND id NOT IN (SELECT id FROM location)
I hope this answers your question.
If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables involved, and also post the results you want from that data.
Explain, using specific examples, how you get those results from that data.
See the forum FAQ: https://forums.oracle.com/message/9362002 -
Combining two tables into one result
Hi all, I am fairly inexperienced with Crystal but have gained good results from the reports I have created, I am fluent in SQL and Basic to an extent. I am interigating a Pronto database and I want concatenate two tables into one report.
Table One: Customer Orders
Fields: Customer No, Invoice Number, Invoice date, Invoice Amount, Cost Amount.
Table Two: Archived Customer Orders
Fields: Customer No, Invoice Number, Invoice date, Invoice Amount, Cost Amount.
I want to complete a report that will tell me the sales for a given period and the outstanding orders for each customer total for all fields in each table combined into one figure.
Any help would be greatly appreciated.
Thanks in advanceHi Grant,
As you said you are goot at writing SQL, in Crystal write a SQL statement in Add Command to join both table using Union / Union all
If you use Union then it will filter duplicate records and pull the data from database, If you use Union All then it will include all your duplicate records. Please use Union / Union All as required.
Once you get all data into the report create a parameter for date range and generate the summaries as required.
Thanks,
Sastry -
My girlfriend and I both have iTunes account with our own music libraries and we want to combine our two libraries into one icloude accounts so can both then access our one shared libary at anytime in the cloud. How do we do this?
No it is not possible. Content purchased from the iTunes Store is permanently tied to the account from which it was originally purchased, and Apple does not provide a way to change it.
-
I opened an itunes account then forgot my password. I opened a new account now I would like to combine my two accounts into one but I still can't remember my password and now I have a new email account. Help!
You can't combine accounts but help here Apple ID FAQ's for resetting your Apple ID password.
-
How do I combine two regents into one in Logic Pro Arrange?
how do I combine two regents into one in Logic Pro Arrange?
Thanks for your input kcstudio. I would still be left with 2 regions although one after the other, on one track.
I am trying to save steps of the way I am combining the info of 2 seperate regions into one: bouncing the 2 tracks then re-importing that audio back into the project. It would save a lot of time if you could just drag one region on top of the other
W.W. -
List aggregate two rows into one
query :
select kod_negeri.NAMA kod_negeri_nama,
hakmilik.id_hakmilik,
MOHON.PENYERAH_NAMA,
MOHON.PENYERAH_ALAMAT1, MOHON.PENYERAH_ALAMAT2, MOHON.PENYERAH_ALAMAT3,
MOHON.PENYERAH_ALAMAT4, MOHON.PENYERAH_POSKOD, MOHON.PENYERAH_KOD_NEGERI,
MOHON.PENYERAH_NO_RUJ, MOHON.ID_MOHON, HAKMILIK.KOD_HAKMILIK, HAKMILIK.NO_HAKMILIK,
KOD_LOT.NAMA, HAKMILIK.NO_LOT, KOD_BPM.NAMA, KOD_DAERAH.NAMA,
LELONG.TMPT, LELONG.DIMASUK, PGUNA.NAMA,
PIHAK.ALAMAT1, pihak.NAMA ven,
PIHAK.ALAMAT2, PIHAK.ALAMAT3, PIHAK.ALAMAT4, PIHAK.POSKOD,
mohon.id_mohon ,
pguna.NAMA pguna_nama,
pguna.JAWATAN,
kod_daerah.NAMA kod_daerah_nama,
to_char(enkuiri.TRH_enkuiri,'DD')||' '|| to_char(enkuiri.TRH_enkuiri,'MONTH','nls_date_language=malay') ||' '||TO_CHAR (enkuiri.TRH_enkuiri, 'YYYY') trh_enkuiri,
to_char(lelong.TRH_lelong,'DD')||' '|| to_char(lelong.trh_lelong,'MONTH','nls_date_language=malay') ||' '||TO_CHAR (lelong.TRH_lelong, 'YYYY') trh_le,
to_char(lelong.trh_lelong, 'Day') day,
to_char(lelong.TRH_lelong,'HH12:MI ') hour,
DECODE(SUBSTR(to_char(lelong.TRH_lelong,'HH12:MI AM'),-2,2),'AM','Petang','pagi') noon,
enkuiri.cara_lelong,
lelong.TMPT,
lelong.HARGA_RIZAB,
enkuiri.harga_rizab,
initcap(pihak.NAMA) pihak_nama,
initcap(lelong.EJA_RIZAB) er,
'RM'||enkuiri.TUNGGAK_AMAUN,
lelong.DEPOSIT,
convert_number_words(lelong.DEPOSIT) as converted_form,
to_char(lelong.TRH_AKHIR_BYR,'DD')||' '|| to_char(lelong.TRH_AKHIR_BYR,'MONTH','nls_date_language=malay') ||' '||TO_CHAR (lelong.TRH_AKHIR_BYR, 'YYYY') TRH_AKHIR_BYR,
to_char(sysdate,'DD') ||' '|| to_char(sysdate,'MONTH','nls_date_language=malay') ||' '||to_char(sysdate,'yyyy') sysd,
kod_bpm.NAMA kod_bpm_nama,
kod_lot.NAMA kod_lot_nama,
hakmilik.NO_LOT,
hakmilik.KOD_HAKMILIK,
hakmilik.NO_HAKMILIK
from
mohon ,
mohon_hakmilik ,
lelong ,
pguna ,
pihak ,
kod_daerah ,
enkuiri ,
kod_bpm ,
hakmilik ,
kod_lot ,
kod_negeri,
mohon_fasa ,
kod_hakmilik
WHERE mohon.id_mohon = mohon_hakmilik.id_mohon and
mohon_hakmilik.id_hakmilik = hakmilik.id_hakmilik and
hakmilik.kod_hakmilik = kod_hakmilik.kod(+) and
hakmilik.kod_lot = kod_lot.kod(+) and
hakmilik.kod_bpm = kod_bpm.kod(+) and
hakmilik.kod_daerah = kod_daerah.kod(+) and
mohon.id_mohon = enkuiri.id_mohon and
lelong.id_pihak = pihak.id_pihak and
lelong.id_mh = mohon_hakmilik.id_mh and
pihak.kod_negeri = kod_negeri.kod(+) and
mohon.id_mohon = mohon_fasa.id_mohon and
mohon_fasa.id_aliran ='semakan' and
mohon_fasa.id_pguna = pguna.id_pguna and
mohon.id_mohon = :p_id_mohon
and enkuiri.KOD_STS='AK'
and mohon.id_mohon ='0405AUC2010007436'KOD_NEGERI_NAMA,ID_HAKMILIK,PENYERAH_NAMA,PENYERAH_ALAMAT1,PENYERAH_ALAMAT2,PENYERAH_ALAMAT3,PENYERAH_ALAMAT4,PENYERAH_POSKOD,PENYERAH_KOD_NEGERI,PENYERAH_NO_RUJ,ID_MOHON,KOD_HAKMILIK,NO_HAKMILIK,NAMA,NO_LOT,NAMA_1,NAMA_2,TMPT,DIMASUK,NAMA_3,ALAMAT1,VEN,ALAMAT2,ALAMAT3,ALAMAT4,POSKOD,ID_MOHON_1,PGUNA_NAMA,JAWATAN,KOD_DAERAH_NAMA,TRH_ENKUIRI,TRH_LE,DAY,HOUR,NOON,CARA_LELONG,TMPT_1,HARGA_RIZAB,HARGA_RIZAB_1,PIHAK_NAMA,ER,'RM'||ENKUIRI.TUNGGAK_AMAUN,DEPOSIT,CONVERTED_FORM,TRH_AKHIR_BYR,SYSD,KOD_BPM_NAMA,KOD_LOT_NAMA,NO_LOT_1,KOD_HAKMILIK_1,NO_HAKMILIK_1
Johor,050503PM00000151,HAMZAH DAUD DAROS & SITI NOR,NO 12 1ST FLOOR & 2ND FLOOR,JLN SRI RAHANG,TMN SRI RAHANG,SEREMBAN,58000,05,12345,0405AUC2010007436,PM,151,Lot,6309,Mukim Lenggeng,Seremban,PTG MELAKA,pptlelong1,Puan Nur Faizati,ASDFSAF,AHMAD,DSFDS,FDSFSDF,DSFSDF,12345,0405AUC2010007436,Puan Nur Faizati,Penolong Pegawai Tanah Lelong (PTD),Seremban,08 DISEMBER 2010,27 JANUARI 2011,Thursday ,02:00 ,pagi,A,PTG MELAKA,,,Ahmad,,RM234,,,24 MEI 2011,10 FEBRUARI 2011,Mukim Lenggeng,Lot,6309,PM,151
,050540HSD00022923,HAMZAH DAUD DAROS & SITI NOR,NO 12 1ST FLOOR & 2ND FLOOR,JLN SRI RAHANG,TMN SRI RAHANG,SEREMBAN,58000,05,12345,0405AUC2010007436,HSD,22923,Lot,0009838,Mukim Jimah,Seremban,PTG MELAKA,pptlelong1,Puan Nur Faizati,no2,Ali Bin Abudillah,jalan 3,taman permata,lorong mentari,32333,0405AUC2010007436,Puan Nur Faizati,Penolong Pegawai Tanah Lelong (PTD),Seremban,08 DISEMBER 2010,27 JANUARI 2011,Thursday ,02:00 ,pagi,A,PTG MELAKA,,,Ali Bin Abudillah,,RM234,,,24 MEI 2011,10 FEBRUARI 2011,Mukim Jimah,Lot,0009838,HSD,22923
KOD_NEGERI_NAMA,ID_HAKMILIK,PENYERAH_NAMA,PENYERAH_ALAMAT1,PENYERAH_ALAMAT2,PENYERAH_ALAMAT3,PENYERAH_ALAMAT4,PENYERAH_POSKOD,PENYERAH_KOD_NEGERI,PENYERAH_NO_RUJ,ID_MOHON,KOD_HAKMILIK,NO_HAKMILIK,NAMA,NO_LOT,NAMA_1,NAMA_2,TMPT,DIMASUK,NAMA_3,ALAMAT1,VEN,ALAMAT2,ALAMAT3,ALAMAT4,POSKOD,ID_MOHON_1,PGUNA_NAMA,JAWATAN,KOD_DAERAH_NAMA,TRH_ENKUIRI,TRH_LE,DAY,HOUR,NOON,CARA_LELONG,TMPT_1,HARGA_RIZAB,HARGA_RIZAB_1,PIHAK_NAMA,ER,'RM'||ENKUIRI.TUNGGAK_AMAUN,DEPOSIT,CONVERTED_FORM,TRH_AKHIR_BYR,SYSD,KOD_BPM_NAMA,KOD_LOT_NAMA,NO_LOT_1,KOD_HAKMILIK_1,NO_HAKMILIK_1
Johor,050503PM00000151,HAMZAH DAUD DAROS & SITI NOR,NO 12 1ST FLOOR & 2ND FLOOR,JLN SRI RAHANG,TMN SRI RAHANG,SEREMBAN,58000,05,12345,0405AUC2010007436,PM and HSD,151 and 22923,Lot,6309,Mukim Lenggeng,Seremban,PTG MELAKA,pptlelong1,Puan Nur Faizati,ASDFSAF,AHMAD,DSFDS,FDSFSDF,DSFSDF,12345,0405AUC2010007436,Puan Nur Faizati,Penolong Pegawai Tanah Lelong (PTD),Seremban,08 DISEMBER 2010,27 JANUARI 2011,Thursday ,02:00 ,pagi,A,PTG MELAKA,,,Ahmad,,RM234,,,24 MEI 2011,10 FEBRUARI 2011,Mukim Lenggeng,Lot,6309,PM,151
that means i need to list aggregate the two rows into one how to make the changes for the above query in order to do so .
Edited by: user9093689 on Feb 9, 2011 10:03 PMuser9093689 wrote:
now need to bother abt this that line converts date into malay language
to_char(enkuiri.TRH_enkuiri,'DD')||' '|| to_char(enkuiri.TRH_enkuiri,'MONTH','nls_date_language=malay') ||' '||TO_CHAR (enkuiri.TRH_enkuiri, 'YYYY') trh_enkuiri,iam retriving two rows of output, wat i need is to display one row and the second row values which are not similar should be added to the first row
for example for column
kod_hakmilik two rows values are
PM
HSD
but they should be display as
PM and HSD
finally my aim is to retrieve only one row as output.
i dont how exactly the term listaggr . how ever it may be whether using groupby or any other but the output should be as aboveWhat version of Oracle are you on?
Look up the LISTAGG() function in the documentation for your version (assuming it is there) and see if it can do what you want -
Combining two messages into one
Hello,
I have a mapping issue, I have a business process in which I have to combine two messages into one.
To do so, I have defined a message mapping in which there are two source message types, and one target message type.
When testing the message mapping in the IR, it works fine, but when I define and test an interface mapping with that same message mapping, I receive this error message:
"Cannot produce target element /ns0:Messages/ns0Message1/MY_IDOC_TYPE/MY_SEGMENT. Check xml instance is valid for source xsd and target-field mapping fulfills requirements of target xsd."
What am I doing wrong ?
How am I supposed to combine two messages into one ?
Thanks,
Elad.Hi Elad,
Just see if you have included both you source message interfaces and one target nessage interface correctly in while doing your interface mapping.....
The most common mistake made when we do scenarios which include combination of two source message types into one target type are:
- we forget to include both the source message interfaces.
- or we interchange between one of the source message interface with the target.
Just see if either of the 2 is aplicable in your case and just activate all components as and when you create them..
Regards,
abhy -
Is it possible to paste two images into one layer?
I'm having some issues pasting two images into one layer. Every time I paste the second image, it automatically creates a new layer...is there anyway to prevent that from happening? I'm making an animation on photoshop and I want there to be more than image in some of the frames. Please let me know if you have any suggestions! Thanks!
You can merge the two layers together once they're position. Select the top layer and choose merge down or select both and choose merge layers (from the layers menu).
http://help.adobe.com/en_US/Photoshop/11.0/WSfd1234e1c4b69f30ea53e41001031ab64-78b2a.html -
Collapsing two tables into one table or one queue
When you have data that exists in 2 tables A and B and B is essentially a child of A if you want to process these records such that you see all A's before their assoociated B how can you use either Streams or AQ to collapse these two tables into one? The data exists at it's source in database tables it will be replicated to another location and at that location I want to keep the data as it exists at the source but also process it in the ordered fashion I described above. My thinking is to publish the data to one queue but the challenge is to ensure that all A's are put on the queue before their B is. I don't just want a priority queue whereby all A's are processed before B's because if that happens B's will never be processed. but I simply want to avoid reading a B off the queue before I've read it's A.
No version number and no clarity of what you are trying to accomplish.
Without knowing that the problem is a nail ... I'd hardly be recommending using a hammer. -
Join the two JInternalFrame into one
hi everybody,
What can I do to join two JInternalFrame into one, like I have 2 floating panel then I join it into 1 by using JTappedPane. That you can drag to spit it out or join together !
thanks,
QuinI think you mean saving two images side-by-side into one image. You won't be able to this with a native iphone app, but you may find a third party app on the AppStore to do this. Try this http://itunes.apple.com/us/app/two-faces-photo-sharing/id406310161?mt=8 if you want more help, email me at [email protected]
-
Is it possible to merge two cubes into one , if so how ??
Hi
Can u please check how we merge two cubes with 1st with 8 dimension ,
and in other 7 dimensions, both has the same dimension.
but in these cube when they r doing the demand planning, they r doing on different levels.
We have one option of merging the cubes but planning across the two cubes
or
same cube with alternate hierarchy.
what all things i have take in to consider while doing this.
Please reply
Maybe you are looking for
-
Problem with JNI and Parallel Port dll
Hi. I'm doing some testes with JNI. Firs i followed the netbeans tutorial for doing a C programa that prints somthing for java.. like.. "Hello java from C". So i tried to load a dll from my dll. Like, I have this dll to use the parallel port on windo
-
I currently have 1,177 photos on my iphone (4s) but it takes up 4.9 GB of space. Why is it so large? I do not use photostream - this is simply within my "Camera Roll". Other than deleting the photos, can someone tell me another solution? My friend ha
-
Subportal doesn't change when the user's group is changed, until next login
Hi, We have two subportals: Physician and Resident. We also have two groups: Physicians and Residents. Users belonging to Physicians see the Physician subportal when they login, and Residents see the Resident suportal. When a Resident becomes a Physi
-
Ho to disabled the parameter on the selection screen
Hi all, I have a parameter (p_matnr) and two radiobutton b1 and b2 on the selection screen. Now what the requirement is if user selects radio button b2, the parameter should get disabled. I know it can be done by <b>loop at screen</b> and then modif
-
Browser inside a Flash/FLex/Air-App with WebGL-Support?
Hello, I´m using Adobe Air/Flex to build a Desktop App. Inside the App the user should be able to access an Internet Browser. This part is actually working so far. BUT: THE ADOBE AIR BROWSER IS NOT SUPPORTING WEBGL. Is there any method to activate