Ask a Question related to Coldfusion Database Access, Design and Development.
-
zu #1
Sum and Group problem with MSSQL
I do a quiet complex query based on users form input. The result looks
something like this (simplified, irrelevant data and fields truncated)
cat_id | producttext
-------------------------------------
1002 | Parma Schinken
1013 | Bordeaux
5006 | Parma Schinken
1005 | Something
1002 | Another Product from Kat 1002
As you can see the first and last record have the same cat_id.
What I want in the end is to know the percentages of products in the same
range (1001-2000, 2001-3000...)
and the percentage of products within the same cat (like 1002)
I do it simply by doing a subquery on each range, see attached code (query1).
The problem is I don't only need the cat_id but it's language dependent name.
I can get it with query like this (see query2) but, it wont function if the
FROM is another query. It only works if I Select from a real table.
Any hints what to do different?
What I actually want in the end is a table like this:
2 1002 Fleisch
1 1005 Beilagen, Pasta, Reis, Konserven
1 1013 Anderes
-- query1 --
SELECT COUNT(*) as Anzahl,cat_id
FROM qgetAuswertung1
WHERE cat_id > 1000 AND cat_id< 2000
GROUP BY cat_id
-- query2 --
SELECT COUNT(*) AS Anzahl,
qgetAuswertung1.users_statdata_productsubcategorie ID,
tCmsElementCustomLieblingsproduktProductSubcategor ie.productsubcategorie_descrip
tion_DE
FROM qgetAuswertung1 INNER JOIN
tCmsElementCustomLieblingsproduktProductSubcategor ie ON
qgetAuswertung1.users_statdata_productsubcategorie ID =
tCmsElementCustomLieblingsproduktProductSubcategor ie.productsubcategorieID
WHERE (qgetAuswertung1.users_statdata_productsubcategori eID > 1000) AND
(qgetAuswertung1.users_statdata_productsubcategori eID <
2000)
GROUP BY qgetAuswertung1.users_statdata_productsubcategorie ID,
tCmsElementCustomLieblingsproduktProductSubcategor ie.productsubcategorie_descrip
tion_DE
zu Guest
-
table alias mssql problem
I get this error: The column prefix 'F' does not match with a table name or alias name used in the query. with the query below Any ideas as... -
MSSQL Stored Procedure Problem
I am trying to pass some variables into a MSSQL stored procedure and for some reason it is truncating the last variable. If I move the order of the... -
Problem with MSSQL connection and PHP
I've written a PHP file to connect to an SQL database. When I use the mssql_connect function, I get this error: Warning: mssql_connect(): Unable... -
[PHP - MSSQL]: Problem with mssql_connect
Please help!... I have to use 'apache+php' connect to MSSQL Server 2000 in Windows Server 2003, but there are problem. Computer A: Windows... -
Problem with mssql driver
Hi Guillaume! On Sun, 24 Aug 2003 10:38:30 +0200, "Guillaume" <nospam_guillaume.rouchon@free.fr> wrote: What is the output of mssql_error()... -
Dan Bracuk #2
Re: Sum and Group problem with MSSQL
You can't use the keyword join in Q of Q. You have to do it the old fashioned way.
select somefields
from query1, query2
where query1.field = query2.field
Dan Bracuk Guest
-
zu #3
Re: Sum and Group problem with MSSQL
This have I done.
I actually didi the Join in the 'base'-query.
Thanks
zu Guest



Reply With Quote

