Wrox Programmer Forums
|
SQL Language SQL Language discussions not specific to a particular RDBMS program or vendor.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Language section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 1st, 2004, 05:04 AM
Ben Ben is offline
Authorized User
 
Join Date: Jun 2003
Posts: 75
Thanks: 0
Thanked 0 Times in 0 Posts
Default Query Help...

I have a table which contains three fields one a fk, one a category (Together they make a composite pk), and finally a value thats associated to the category. Each fk can have up to 9 category's with values, if a category has no value no entry would be made (Every fk will have at least 1 category).

Essientially I need to CrossTab this table, so I have the fk as a column with nine category columns filled with their values. I figured as we always want to report all nine categories and the number of categories is static, the most apt way of doing this would be a case statement with coalesce to treat the nulls, however I need to do this in an access data project which doesn't support the case statement

The quickest way I can think to do this now is through nine subqueries breaking the original table into nine new tables based on the categories - I figure this is quicker than doing 9 outer joins based on the original table and a Where Not Category = 1 or category = 2, etc. Can anyone confirm I'm going the right way?

I guess the other question I'd like to ask is if there would be a gain saving the subqueries as views and reference them, or specifying them all in one big query.
 
Old October 1st, 2004, 08:21 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Cross post at http://p2p.wrox.com/topic.asp?TOPIC_ID=19997

_________________________
- Vijay G
Strive for Perfection
 
Old October 11th, 2004, 08:41 AM
Ben Ben is offline
Authorized User
 
Join Date: Jun 2003
Posts: 75
Thanks: 0
Thanked 0 Times in 0 Posts
Default

And?





Similar Threads
Thread Thread Starter Forum Replies Last Post
Output Query to txt file from SQL Query everest SQL Server 2005 4 November 22nd, 2007 01:49 AM
how to make a query from an existing query raport SQL Language 3 November 13th, 2006 08:59 PM
I solved insert query.now see this Update Query. amit_mande@yahoo.com VB.NET 2002/2003 Basics 2 September 21st, 2006 12:48 AM
Syntax error in query. Incomplete query clause. dispickle ADO.NET 3 April 16th, 2004 01:04 PM
Error on Make-Table Query In Union Query rylemer Access 1 August 20th, 2003 07:42 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.