i have a sql anywhere database which have 3 table

(1)  accounttype
----------------
catid    smallint
catname   varchar (20)
----------------------------
data values
catid    catname    
1      Expenditure
2       Income
3       Assets
4       Liabilities
-----------------------------
(2)  accounts
-------------
code integer
name varchar(30)
type smallint
-----------------------
type column has foreign key to  catid from accounttype table
---------------------------
data values
code    name                  type
712001  General expenses    1
712002  Rent account    1
712003  Salaries Account    1
711001  Purchases   1
711002  Purchases return    1
811001  Sales Account   2
811002  Sales Return    2
411001  Furniture account   3
632001  Bank Account    3
642001  Bills receiable 3
631001  Cash Account    3
222001  Bill Payable    4
221020  Jayaram Bros    4
110001  Capital Account 4
=========================
(3)  voucher
-----------
vno        integer
debit      integer
vdate     date
amount  numeric(15, 2)
credit     integer 
debit and credit column has foreign key to code from accounts table
vno debit   vdate        amount             credit
1   631001  01-04-2018     500000.00      110001
2   632001  01-04-2018     400000.00      631001
3   711001  02-04-2018      150000.00     632001
4   712002  02-04-2018       9000.00       632001
6   711001  03-04-2018       50000.00      631001
7   711001  05-04-2018       250000.00    221020
8   631001  06-04-2018      45000.00       811001
9   711002  10-04-2018      15000.00      221020
10  221020  19-04-2018       235000.00   222001
11  811002  21-04-2018       5000.00       632001
12  411001  28-04-2018      45000.00     632001
13  411001  29-04-2018      35000.00     711001
14  712001  30-04-2018       9000.00      632001
15  712001  30-04-2018       5500.00      632001

sir, i want to generate profit and loss statement from the above tables i am facing difficulties to generate the sql for the profit and loss statement Does anybody know how to get the profit and loss statement?

regards kumar

asked 01 Aug, 05:51

ghkumarchd's gravatar image

ghkumarchd
254
accept rate: 0%

edited 01 Aug, 06:44

Volker%20Barth's gravatar image

Volker Barth
32.2k328474688

So what have you tried so far? What does your SQL statement(s) look like?

(01 Aug, 06:45) Volker Barth
Replies hidden
3

(01 Aug, 07:49) Breck Carter

thanks for the response this is the sql code I tried, but it doesn't gives the correct order SELECT "vouchers"."debit",
SUM("vouchers"."amount" ),
"vouchers"."credit",
"accounts"."code",
"accounts"."type"
FROM "accounts",
"vouchers"
WHERE ( "vouchers"."debit" = "accounts"."code" ) and
( ( "accounts"."type" = :typ ) OR ( "accounts"."type" = :typo ) )
Group by "vouchers"."debit", "vouchers"."credit", "accounts"."code", "accounts"."type"

please anybody have a solution, it will be helpful

regards kumar

permanent link

answered 02 Aug, 01:34

ghkumarchd's gravatar image

ghkumarchd
254
accept rate: 0%

edited 02 Aug, 01:36

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×32
×9

question asked: 01 Aug, 05:51

question was seen: 71 times

last updated: 02 Aug, 01:36