I wrote an sql query which pulls data from a single table ( date,account,dr,cr
) depending upon a condition as follows:
select * from (select date,account,dr from sys_credit_debit where dr != 0) as t1,
(select date,account,cr from sys_credit_debit where cr != 0) as t2
I want to show the debit data on left side of the table and credit data on the right side. knowing the fact that rows can be different. But, I am getting the double data through the query.
Can anybody help me?
Try below query
SELECT t1.*,t2.* FROM
(select date,account,dr from sys_credit_debit where dr != 0) as t1
INNER JOIN
(select date,account,cr from sys_credit_debit where cr != 0) as t2
ON t1.account = t2.account AND t1.date = t2.date
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.