Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Tough problem for me, ez to you??? Help!
Message
 
 
To
05/07/2002 15:00:28
General information
Forum:
Microsoft SQL Server
Category:
Security
Miscellaneous
Thread ID:
00675732
Message ID:
00675842
Views:
8
If you've exactly 4 cats, than
SELECT catgroup, 
       SUM( IIF(cat = "cat1", 1, 0)) AS cat1, 
       SUM( IIF(cat = "cat2", 1, 0)) AS cat2, 
       SUM( IIF(cat = "cat3", 1, 0)) AS cat3, 
       SUM( IIF(cat = "cat4", 1, 0)) AS cat4, 
  GROUP BY catgroup ORDER BY catgroup
BTW, what it has to do with MS SQL security? :)

>I am attempting to display a table within an .asp page from their database. What my client wants to see:
>
>___________cat1 | cat2 | cat3 | cat4 |
>group1______5__|___2__|___4__|___4___|
>group2______4__|___2__|___0__|___0___|
>group3______1__|___0__|___2__|___2___|
>
>My plan was to use a query for each cat to come up with the 4 different columns, like this:
>
>SELECT Count(cat) as Expr1, cat, group
>FROM dbo.Open_DurationsTable1
>WHERE cat = 'cat2' Group By group, cat
>
>This works fine except for that fact that certain combinaitons don't exist, therefore there is no data returned, for example, when the query is ran for cat1, each group is returned with a corresponding count. If ran for cat2, only group1 and group2 are returned, nothing is returned for group3 as it doesn't exist. Both the catagory and group are in the same table, and the goups and catagories each have their own table with no other info in them (did that to see if query 2 tables at once might help). My question is, is there a way to construct a query that would display the count for each group, even if there isn't a result for each group. Since this is written for use in an .asp page, is thre maybe a way to have some .asp code read the query results and fill in the gaps? Confusing enough?
--sb--
Previous
Reply
Map
View

Click here to load this message in the networking platform