?
Solved

dynamic grouping

Posted on 2005-04-26
5
Medium Priority
?
194 Views
Last Modified: 2010-03-19
how can i create a group by query  where from my database automatically it will display on page  all categories and subcategories  based on the information in my tables

for instance something like this

Forms
  form a
  form b

News
  news a
  news b

Links
  links a
  link b

and my table looks like this

departments

departmentid|  departmentname

Categories

categorieid|departmentid| categoriename

Subcategories

subcategorieid| categorieID | Subcategorieinfo


is there is a solution that creates this please send me a link to evaluate.

thanks
0
Comment
Question by:gianitoo
  • 3
  • 2
5 Comments
 
LVL 34

Accepted Solution

by:
Brian Crowe earned 2000 total points
ID: 13870650
would this work for you?

SELECT departments.*, categories.*, subcategories.*
FROM departments
INNER JOIN categories
     ON departments.departmentid = categories.departmentid
INNER JOIN subcategories
     ON categories.categoryid = subcategories.categoryid
ORDER BY departments.departmentname, categories.categoryname, subcategories.subcategoryinfo
0
 
LVL 1

Author Comment

by:gianitoo
ID: 13870692
do you see how in crystal reports you can group by a categorie and automatically tab the subcategories

for example:

Food
    apple
    tomatos

Clothes
   jacket
   tshirt

and lets say that i add another categorie called cars with 2 subcategories and utomatically gets added as seen below

Food
    apple
    tomatos

Clothes
   jacket
   tshirt

Cars
  Porshe
  Mazda

do i make sense?

i know how to do this but by writing multiple queries for each categorie.   it nees to be done dinamically to eliminate worktime
   
0
 
LVL 1

Author Comment

by:gianitoo
ID: 13871122
this is an example

http://www.sharepointcustomization.com/finance/default.aspx

view the finance team categorie
0
 
LVL 34

Expert Comment

by:Brian Crowe
ID: 13872593
I believe in the case example you are providing that they are using a version of a datagrid with a related child table.  The example I provided is how I would solve the problem in Crystal.
0
 
LVL 1

Author Comment

by:gianitoo
ID: 13872683
ok thanks
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
This shares a stored procedure to retrieve permissions for a given user on the current database or across all databases on a server.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Viewers will learn how the fundamental information of how to create a table.
Suggested Courses

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question