BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

help with one sql query for MySQL

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (SQL Servers)
View previous topic :: View next topic  
Author Message
Boki
Guest





PostPosted: Sun Aug 17, 2003 6:08 pm    Post subject: help with one sql query for MySQL Reply with quote



Hi

I have one standard table for displaying history of single Article in
accountancy:
------------------------
id Autoincrement INT
description CHAR(16)
input INT
output INT

Can somebody to help me to display this
------------------------------------------------------------
description input output balance
------------------------------------------------------------
beginning 5 0 15
new sale 0 6 9
new supply 3 0 12
sale 2 0 4
8
One more supply 7 0 15

How to display first 3 columns and to calculate "balance" all within one sql
query (with or without subqueries)

great thanks
Bojan


Back to top
J O Holloway
Guest





PostPosted: Sun Aug 17, 2003 6:44 pm    Post subject: Re: help with one sql query for MySQL Reply with quote



It's difficult for me to know what your intent is, since (at least on a
record by record basis) the balance doesn't seem to be the result of the
difference between the input and the output. I'll take a stab at it, but if
I'm off then it would help if you would post an explanation on what you're
trying to do. Also, it is wildly helpful to post the create table statement
and insert statements; doing that makes it easier (and more likely) for
others to try to assist you.

select
[description],
input,
[output],
input - [output] as balance
from table_of_Article_histories --I wasn't sure what the table name really
was

As you can see, two of those fieldnames are wrapped in brackets. That's
because those words are reserved in SQL Server. In future it would be best
to avoid using them as field names.


"Boki" <nikolic-nospam-bojan (AT) hotmail (DOT) com> wrote

Quote:
Hi

I have one standard table for displaying history of single Article in
accountancy:
------------------------
id Autoincrement INT
description CHAR(16)
input INT
output INT

Can somebody to help me to display this
------------------------------------------------------------
description input output balance
------------------------------------------------------------
beginning 5 0 15
new sale 0 6
9
new supply 3 0 12
sale 2 0 4
8
One more supply 7 0 15

How to display first 3 columns and to calculate "balance" all within one
sql
query (with or without subqueries)

great thanks
Bojan





Back to top
Boki
Guest





PostPosted: Sun Aug 17, 2003 8:39 pm    Post subject: Re: help with one sql query for MySQL Reply with quote



Hi

your sql don't help :)

balance need to be calculated (as can be seen in example):
new balance = balance from past row + (input - output)

Thanks
Boki

"J O Holloway" <jholloway (AT) pinncorp (DOT) com> wrote

Quote:
It's difficult for me to know what your intent is, since (at least on a
record by record basis) the balance doesn't seem to be the result of the
difference between the input and the output. I'll take a stab at it, but
if
I'm off then it would help if you would post an explanation on what
you're
trying to do. Also, it is wildly helpful to post the create table
statement
and insert statements; doing that makes it easier (and more likely) for
others to try to assist you.

select
[description],
input,
[output],
input - [output] as balance
from table_of_Article_histories --I wasn't sure what the table name
really
was

As you can see, two of those fieldnames are wrapped in brackets. That's
because those words are reserved in SQL Server. In future it would be
best
to avoid using them as field names.


"Boki" <nikolic-nospam-bojan (AT) hotmail (DOT) com> wrote in message
news:3f3fc4fc (AT) newsgroups (DOT) borland.com...
Hi

I have one standard table for displaying history of single Article in
accountancy:
------------------------
id Autoincrement INT
description CHAR(16)
input INT
output INT

Can somebody to help me to display this
------------------------------------------------------------
description input output
balance
------------------------------------------------------------
beginning 5 0
15
new sale 0 6
9
new supply 3 0 12
sale 2 0 4
8
One more supply 7 0 15

How to display first 3 columns and to calculate "balance" all within one
sql
query (with or without subqueries)

great thanks
Bojan







Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (SQL Servers) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.