Source language: Translate to:

merging datas idea?

Questions about our Advanced Database plug-in

Moderator: Neosoft Support

merging datas idea?

Postby yanzco » Wed Feb 25, 2015 12:21 pm

i was stuck on this..

i have a table..
queried results like

apple 1
banana 2
mango 1
apple 5
cherry 2
peanut 2
mango 2
and so on.. etc..

i wanted to show the merged results in a box or text like this
apple 6
banana 2
mango 3
cherry 2
peanut 2

any ideas how i can do that?
yanzco
 
Posts: 175
Joined: Sun Jul 20, 2014 4:07 am

Re: merging datas idea?

Postby stu » Wed Feb 25, 2015 3:09 pm

Try this:

Syntax: [ Download ] [ Hide ]
Using SQL Syntax Highlighting
SELECT fruit, SUM(amount) AS Total FROM t1 GROUP BY fruit
Parsed in 0.005 seconds, using GeSHi 1.0.8.10
User avatar
stu
 
Posts: 318
Joined: Wed Aug 07, 2013 11:37 am

Re: merging datas idea?

Postby yanzco » Wed Feb 25, 2015 6:04 pm

hmmm.. i kinda tried it.. not sure.. but

the table is displayed as a record of the food eaten on that day..
so it could be a long list..

i need that long list to be displayed...
and at the same time..

i want to display at least something like this when the user clicks on the table..

lets say, ont the list.. i clicked apple..
the text beside the table shows.. apple : 6
or if i click banana on the table.. it would show.. banana 2

doing the above without changing the queried table
apple 1
banana 2
mango 1
apple 5
cherry 2
peanut 2
mango 2
and so on.. etc..

:o
yanzco
 
Posts: 175
Joined: Sun Jul 20, 2014 4:07 am

Re: merging datas idea?

Postby Gaev » Wed Feb 25, 2015 11:03 pm

yanzco:

1) What is the "database id" ?

2) What is the "table" ?

3)
the table is displayed as a record of the food eaten on that day..

What is the "filter" you use in your dbpQuery command for this ?

lets say, ont the list.. i clicked apple..
the text beside the table shows.. apple : 6
or if i click banana on the table.. it would show.. banana 2

a) you can expand the SQL command from stu with a "WHERE clause" that filters the records the same way as you would in dbpQuery.

b) in order to get the "sum of just the selected fruit" ... you would expand the "WHERE clause" further to include just the "selected fruit name" ... and you can get the "selected fruit name" using the special NeoBook variable [yourID.yourTableName.yourFruitField].
User avatar
Gaev
 
Posts: 3718
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Re: merging datas idea?

Postby stu » Thu Feb 26, 2015 5:55 am

Here's pretty much the same query using a WHERE clause so you can have only results for this year, in this case about Computer Equipment, using only 3 fields of the table.

Image

Maybe you should create a view instead of using the contents of your original table. But yeah, I didn't quite get your second post, if you can elaborate a bit more that would be great.
User avatar
stu
 
Posts: 318
Joined: Wed Aug 07, 2013 11:37 am


Return to NeoBookDBPro

Who is online

Users browsing this forum: No registered users and 2 guests

cron