Hi folks
I am having difficuly sussing out how to join while using a group by clause.
table one is a variable (@t)
constructed thus:
declare @t table
([id] int IDENTITY(1,1)
PRIMARY KEY CLUSTERED,
cid int)
I do some manipulations on it then I select a results list thus:
select Count(*) as p,cid from @t
group by cid
order by p desc
which gives me the number of times cid appears in @t for each cid as p and cid itself. All okay so far.
cid is a primary key in the clients table and I want to pull all the client data for each cid (row) in the results
how do I construct the join?
any suggestions?
Sorry if it's not clear.
I am having difficuly sussing out how to join while using a group by clause.
table one is a variable (@t)
constructed thus:
declare @t table
([id] int IDENTITY(1,1)
PRIMARY KEY CLUSTERED,
cid int)
I do some manipulations on it then I select a results list thus:
select Count(*) as p,cid from @t
group by cid
order by p desc
which gives me the number of times cid appears in @t for each cid as p and cid itself. All okay so far.
cid is a primary key in the clients table and I want to pull all the client data for each cid (row) in the results
how do I construct the join?
any suggestions?
Sorry if it's not clear.