|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Show all names after WHERE
Hello,
Here is one of my current queries: SELECT name, sum(duration) FROM master WHERE class like '%tivoli 1%' and class not like '%tivoli 2%' group by name; This will give a result of: Name1 6.5 Name3 50 Name6 64 but i would like the result to be: Name1 6.5 Name2 0 Name3 50 Name4 0 Name5 0 Name6 64 Name7 0 etc. This seems so simple but i cannot figure out how to do it, i've tried isnull, coalesce, having sum(duration)>-1. Any help appreciated. I've had r937's help in the MySQL forums to get it working in MySQL. BUT i also need it to work in MS Access 2002! If anyone's got any ideas, it's more than appreciated. Thanks. |
|
#2
|
|||
|
|||
|
Quote:
![]() |
|
#3
|
|||
|
|||
|
I *think* I know what you mean.. I created what you wanted but... needed to use a lookup (Listing all of the 'names.. name1-name7' and then left joining against it...)
Anyway if its no use sorry, otherwise : SELECT ListOfAllNames.ListNames, Sum(Master.value) AS SumOfvalue FROM ListOfAllNames LEFT JOIN Master ON ListOfAllNames.ListNames = Master.name WHERE (((Master.class) Is Null Or ((Master.class) Like "*tivoli 1*" And (Master.class) Not Like "*tivoli 2*"))) GROUP BY ListOfAllNames.ListNames; |
|
#4
|
|||
|
|||
|
Quote:
Hi thanks for the reply. The query you listed is what i have working in MySQL (thanks to R937 in the MySQL forums) but MS Access 2002 does not like it, do you have any ideas why?/how to work around it? And yes, what you did get the right idea of what i meant. |
|
#5
|
||||
|
||||
|
try this --
Code:
SELECT names.name
, SUM(tivoli.duration) AS master_duration
FROM ( SELECT DISTINCT name
FROM master ) AS names
LEFT OUTER
JOIN ( SELECT name
, duration
FROM master
WHERE class LIKE '%tivoli 1%'
AND class NOT LIKE '%tivoli 2%' ) as tivoli
ON tivoli.name = names.name
GROUP
BY names.name;
![]() |
|
#6
|
|||
|
|||
|
Quote:
Yeah already tried both the % and *'s, but still not able to get it working. |
|
#7
|
||||
|
||||
|
Quote:
|
|
#8
|
|||
|
|||
|
Quote:
MS ACCESS? The suspense is killing me! |
|
#9
|
|||
|
|||
|
Anyone?
|
|
#10
|
|||
|
|||
|
Not too sure sorry, works fine in access 2003 for me! (The one I wrote).. all can think is to check all the column data types, tried it without wildcards to get a direct match first? (And eliminate them being the problem)
|
![]() |
| Viewing: Dev Shed Forums > Databases > Database Management > Show all names after WHERE |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|