I eventually came up with a solution myself although the query is a bit
different
SELECT C.file, C.digest, (a.cnt_A + b.cnt_B) AS total_count, C.refcount FROM C,
(SELECT file, digest, COUNT(file) AS cnt_A FROM A GROUP BY file, digest) as a,
(SELECT file, digest, COUNT(file) AS cnt_B FROM B GROUP
Hi Aveek,
You need to use something like union all and having to get desire result
Follow example below
select file, digest from
(
SELECT file, digest,Count(*) as Cnt FROM A GROUP BY file, digest
union all
SELECT file, digest,Count(*) as Cnt FROM B GROUP BY file, digest
) tmp
group by file,
Peter Brawley wrote:
Micah,
>each item in `a` has a 1 to 1 relationship to `b`,
>and each item in `c` has a 1 to 1 relationship with `b`.
>Sometimes these correspond, i.e. there's a row in `b`
>that relates to both `a` and `c`, but not always.
So in a given b row, the b_id value might match an
Micah,
>each item in `a` has a 1 to 1 relationship to `b`,
>and each item in `c` has a 1 to 1 relationship with `b`.
>Sometimes these correspond, i.e. there's a row in `b`
>that relates to both `a` and `c`, but not always.
So in a given b row, the b_id value might match an a.a_id, a c.a_id, or
shaun thornburgh schrieb:
> Thanks for your reply, I would like the query to retun one
> instance of user 101 rather than 15!
SELECT DISTINCT ...
Regards,
A.
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED
from the first table
From: "shaun thornburgh" <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED], mysql@lists.mysql.com
Subject: Re: Help with a query please
Date: Mon, 21 Feb 2005 13:24:55 +
From: "Rhino" <[EMAIL PROTECTED]>
To: "shaun thornburgh"
<[
From: "Rhino" <[EMAIL PROTECTED]>
To: "shaun thornburgh"
<[EMAIL PROTECTED]>,
Subject: Re: Help with a query please
Date: Mon, 21 Feb 2005 08:22:29 -0500
- Original Message -
From: "shaun thornburgh" <[EMAIL PROTECTED]>
To:
Sent: Monday
- Original Message -
From: "shaun thornburgh" <[EMAIL PROTECTED]>
To:
Sent: Monday, February 21, 2005 7:28 AM
Subject: Help with a query please
> Hi,
>
> I am having trouble with the following query:
>
> SELECT U.User_ID,
> U.User_Firstname,
> U.User_Lastname
> FROM Users U, Allocation
In article <[EMAIL PROTECTED]>,
"Graham Cossey" <[EMAIL PROTECTED]> writes:
> I'm hoping someone can help with a little problem I'm having with a query.
> In the query below I wish to return as least one row per tbl1, however I am
> only getting rows where there is at least an entry for tbl2 :
>
lists.mysql.com
> Subject: RE: Help with a query using multiple LEFT JOINS
>
>
> If you mean that you want to get a row even if tbl2 does not have
> a matching
> row for dcode, then move the conditions into the ON clause.
>
> Example based off of what you had:
>
> SELE
If you mean that you want to get a row even if tbl2 does not have a matching
row for dcode, then move the conditions into the ON clause.
Example based off of what you had:
SELECT
FROM tbl1 as d
LEFT JOIN tbl2 as r ON (d.dcode=r.dcode AND r.mcode='AB' AND r.year=2004 AND
r.month IN (1,2,3,4,5,6,7,
[EMAIL PROTECTED] wrote:
I think you may have introduced the >From typo
! Try looking at a mailbox in a text editor -- you'll notice that
the string 'From ' occuring at the beginning of a line is used as
the message separator.
Thus when that string occurs within a message body, it needs to be
es
9:44 AM
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: RE: Help with a query
Quoting [EMAIL PROTECTED]:
Sounds like you want to do:
Select store_name, t1mgr.manager_name as 'type_1_manager',
t2mgr.manager_name as 'type_2_manager'
From (keystone_stores ks left join manage
: [EMAIL PROTECTED]
Subject: RE: Help with a query
Quoting [EMAIL PROTECTED]:
>
> Sounds like you want to do:
>
> Select store_name, t1mgr.manager_name as 'type_1_manager',
> t2mgr.manager_name as 'type_2_manager'
> >From (keystone_stores ks left join
Quoting [EMAIL PROTECTED]:
>
> Sounds like you want to do:
>
> Select store_name, t1mgr.manager_name as 'type_1_manager',
> t2mgr.manager_name as 'type_2_manager'
> >From (keystone_stores ks left join managers t1mgr on ks.id =
> t1mgr.store_id
> and t1mgr.manager_type = 1)
> Left join managers t2
Sounds like you want to do:
Select store_name, t1mgr.manager_name as 'type_1_manager',
t2mgr.manager_name as 'type_2_manager'
>From (keystone_stores ks left join managers t1mgr on ks.id = t1mgr.store_id
and t1mgr.manager_type = 1)
Left join managers t2mgr on ks.id = t2mgr.store_id
and t2mgr.mana
Ajay Patel - SunService wrote:
>I am a beginner at SQL and would appreciate any help with a simple
>query.
>
>I have two tables:
>
>host
>patch
>
>The host table contains details for a particular host (OS, cpus, memory, etc)
>and the patch table contains patches installed on that host.
>
>For e
select hostid,patch.patchnumber from host
left join patch on host.hostid = patch.hostid
where patchnumber isnull
-Original Message-
From: Ajay Patel - SunService [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, August 21, 2002 2:27 PM
To: [EMAIL PROTECTED]
Subject: help with a query
I am
18 matches
Mail list logo