• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

charts - primefaces

 
Greenhorn
Posts: 26
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

I have a table called CHANGES with a field called as STATUS.
There are 3 values for the STATUS  (Open, Closed, Canceled)

How could I show the quantity for each one in the primefaces charts pie ?

If I do a separate SQL as example (SELECT status from CHANGES where status='Open'), sure...I see the quantity for each one... open, closed or canceled.

But, I would like to show all status together in the charts.

Example:
Open = 10
Closed = 5
Canceled = 1

How is it possible?

I am trying to do this, but is a litte confuse for me.

Any help will be appreciated. Thnks

BEAN



DAO


 
Marshal
Posts: 79475
379
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Question too difficult for the “beginning” forum: moving.
 
Saloon Keeper
Posts: 10815
86
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows ChatGPT
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rafael Ra wrote:I would like to show all status together in the charts.
Example:
Open = 10
Closed = 5
Canceled = 1


You can have the database do the work for you with GROUP BY. You'll have to change the result set getxxx() to reflect that now you'll be getting two fields: count, and status. You may have to retrieve them by column index instead of column name.


 
Rafael Ra
Greenhorn
Posts: 26
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Carey Brown.

Thanks for your reply.

yeah... using this select I got sql error (java.sql.SQLException: Column 'id' not found.),

I will search how to retrieve them by column index instead of column name and I back here to post.
 
Rafael Ra
Greenhorn
Posts: 26
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Update: I left the same name (COUNT(id) on the resultset and it is working fine hehe



but returning to the subject of the retrieve by column index instead of column name, what would be the difference using by index in my results? Thanks!
 
Carey Brown
Saloon Keeper
Posts: 10815
86
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows ChatGPT
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try indexes, like this...


 
Carey Brown
Saloon Keeper
Posts: 10815
86
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows ChatGPT
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can also use an alias so that you could retrieve by name. The alias must not be an SQL reserved word, so "count" is out but you could use something like "kount", "cnt", or "qty".
 
Rafael Ra
Greenhorn
Posts: 26
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
both examples worked, but not setCount.

correct: chg.setId(rs.getInt(1));

Thank you so much!

 
Carey Brown
Saloon Keeper
Posts: 10815
86
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows ChatGPT
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're welcome.

I changed setId() to setCount() because the data no longer represents an id but a count. Of course this would require updating your class to substitute "count" for "id" wherever it occurs.
reply
    Bookmark Topic Watch Topic
  • New Topic