Click here to Skip to main content
15,885,537 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In my table has following

Ledger_Transaction_hdr
Lth_comp   LTH_SNO  Lth_ledgerid  Lth_trantype  lth_total  lth_paid  lth_received
3          7            1              PR          10000      10000      0
3          7            5              PR           2000      0         10000
3          8            1              SR           2000      10000      0
3          8            15             SR           3000      0         10000
3          5            3              SL           10000      10000       0
3          5            4               SL          1000       0        10000
3          5            5               SLRCPT          1200       1200       0
3          5            5               SLRCPT      1200       0       1200


IN THE ABOVE TABLE I WANT TO DETAILS FOR LEDGER ID 1 like following


Lth_comp   LTH_SNO  Lth_ledgerid  Lth_trantype  lth_total  lth_paid  lth_received
3          7            5              PR           2000      0         10000
3          8            15             PR           3000      0         10000

how to get it I give the ledgerid 1
it returns the transaction from 1 depending on lth_sno how to do it please help me anybody thankyou


If i give this query
Select * from ledger_transaction_hdr where lth_Transrlno in (select lth_transrlno from ledger_transaction_hdr where lth_ledgerid=1)


It give the folloing
Lth_comp   LTH_SNO  Lth_ledgerid  Lth_trantype  lth_total  lth_paid  lth_received
3          7            5              PR           2000      0         10000
3          8            15             PR           3000      0         10000
3          5            5              SLRCPT         1200       1200       0
3          5            5              SLRCPT        1200       0       1200

But I don't want like that. I want First Solutions
Posted
Updated 20-Jul-12 19:46pm
v13
Comments
Arul R Ece 19-Jul-12 7:47am    
Can't understand your Question.please explain in detail
devausha 20-Jul-12 3:23am    
In this table I want to get the records is not equalto ledger id 1 but sno of the ledger id 1 is 7 which is equal to which rows has sno 7

devausha 19-Jul-12 7:49am    
I want to get the transaction with ledgerid 1

I think its join you are looking for. Have a look here:
http://msdn.microsoft.com/en-us/library/ms191517%28v=sql.105%29.aspx[^]

Good luck!
 
Share this answer
 
SQL
select * from ledger_transaction_hdr a where lth_sno in (Select lth_sno from ledger_transaction_hdr where lth_ledger_id=1)


or

select * from ledger_transaction_hdr a where exists (Select lth_sno from ledger_transaction_hdr where lth_ledger_id=1)
 
Share this answer
 
Comments
devausha 20-Jul-12 6:59am    
I try this solution But there is some problem if there are two many
I update the above questions
Santhosh Kumar Jayaraman 20-Jul-12 7:01am    
I didnt get you. What was the issue you are facing now?
devausha 20-Jul-12 7:07am    
I explain it on the question. Please see that
Santhosh Kumar Jayaraman 20-Jul-12 7:48am    
i have posted new answer.Please check and let me know
SQL
select * from  Ledger_Transaction_hdr where  Lth_trantype ='PR' and lth_paid =0

you want like that
 
Share this answer
 
v3
SQL
Select * from ledger_transaction_hdr where lth_Transrlno in (select lth_transrlno from ledger_transaction_hdr where lth_ledgerid=1) and  lth_ledgerid<>1
 
Share this answer
 
v2
Comments
devausha 20-Jul-12 7:59am    
I already try this one but it is not working
Santhosh Kumar Jayaraman 20-Jul-12 8:11am    
Can you share screenshot of ur query and output?
devausha 21-Jul-12 0:13am    
Yes
devausha 21-Jul-12 0:36am    
But How to upload image?
Santhosh Kumar Jayaraman 23-Jul-12 1:40am    
http://tinypic.com/

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900