|
Re: Help Needed Regarding the following Query [message #185013 is a reply to message #184984] |
Sun, 30 July 2006 00:54 |
Frank
Messages: 7901 Registered: March 2000
|
Senior Member |
|
|
Use decode to select the p- and r-amounts depending on the value of transaction.
Try this yourself first as this is very basic SQL. If you are stuck, come back and show us what you did.
Next time, please post your question directly in your post; not as an attachment.
You can read in the first couple of posts in the forum how to format your text. (You can use [code] and [/code] tags around your code part)
|
|
|
Re: Help Needed Regarding the following Query [message #185017 is a reply to message #185013] |
Sun, 30 July 2006 01:42 |
vivekanandaan
Messages: 8 Registered: July 2006
|
Junior Member |
|
|
Hi Frank,
SELECT BILL_NO,CUST_NO,DECODE(TYPE,'P',AMT,0) P_AMT,DECODE(TYPE,'R',AMT,0) R_AMT,AMT
FROM BILL_ADD;
The above query works fine.
Thanks a lot.
Regards
R.Vivek
|
|
|
|
|
Re: Help Needed Regarding the following Query [message #185047 is a reply to message #185029] |
Sun, 30 July 2006 11:46 |
Frank
Messages: 7901 Registered: March 2000
|
Senior Member |
|
|
Well, wrap all of your query in a "select * from" and you got a solution with a subquery.
I just can't understand why these interviewers keep on asking such idiotic and totally irrelevant questions. Your query looks just fine to me!
|
|
|
Re: Help Needed Regarding the following Query [message #185092 is a reply to message #184984] |
Mon, 31 July 2006 00:11 |
vivekanandaan
Messages: 8 Registered: July 2006
|
Junior Member |
|
|
Hi to all,
I got it.
Below is the query :
SELECT BILLNO,CNO,AMT AS P_AMT, 0 as R_AMT,AMT
FROM DAILYBILL where type='Purchase'
UNION ALL
SELECT BILLNO,CNO,0 AS P_AMT, AMT as R_AMT,AMT
FROM DAILYBILL where type='Settlement';
Thanks & Regards
R.Vivekanandaan
|
|
|
|