Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Select query help

Author  Topic 

gangadhara.ms
Aged Yak Warrior

549 Posts

Posted - 2010-08-02 : 01:21:37
Hi All,
I am very new to programming i need help for this.

I have fixed select query and it returns some 64 number of rows.
ouputresultset:

meetingid/namegive,namefamily/date/eventname

select m.id as meeting_id, r.NameGiven,r.NameFamily,e.* from event e
join Employee r ON r.id = e.rep_id
left join meeting m on m.event_id = e.id
where marketingprogram_id in (19,24)
and eventstatus_id = 5
order by marketingprogram_id

I need to get the count of persons atteded with all the above column with some other 2 tables,.

1.meeting_invitee
2.meeting_otherattendees

based on meeting_id column

Can somebody pls help me for query to that.

Thanks,
Gangadhar

slimt_slimt
Aged Yak Warrior

746 Posts

Posted - 2010-08-02 : 01:40:58
please post schema for both tables (that is Employee and meeting).
Go to Top of Page

gangadhara.ms
Aged Yak Warrior

549 Posts

Posted - 2010-08-02 : 01:56:10
Hi All,

I got some improvement and written query,Again i got stuck here ,,

there are 2 queries
1..

select a.* ,count(*)as NbrOfAttendees from
meeting_invitee bb inner join
(select m.id as meeting_id, r.NameGiven,r.NameFamily,e.EventName,
e.marketingprogram_id from event e
join Employee r ON r.id = e.rep_id
left join meeting m on m.event_id = e.id
where marketingprogram_id in (19,24)
and eventstatus_id = 5
)a on bb.meeting_id=a.meeting_id
group by a.meeting_id,NameGiven,NameFamily,EventName,marketingprogram_id
order by marketingprogram_id



and

2...


select a.*,NbrOfAttendees from
meeting_otherAttendees bb inner join

(select m.id as meeting_id, r.NameGiven,r.NameFamily,e.EventName,
e.marketingprogram_id from event e
join Employee r ON r.id = e.rep_id
left join meeting m on m.event_id = e.id
where marketingprogram_id in (19,24)
and eventstatus_id = 5) a on bb.meeting_id=a.meeting_id
--group by a.meeting_id,NameGiven,NameFamily,EventName,marketingprogram_id
order by marketingprogram_id


From the above 2 queries i need to fetch SUM(addition) of NbrOfAttendees if meeting_id exist in both the table ,if not as it is it should come.

I need your help pls in this regard,
Go to Top of Page

slimt_slimt
Aged Yak Warrior

746 Posts

Posted - 2010-08-02 : 06:34:38
it's hard to help if one does not know the table schema and some sample data. thank you
Go to Top of Page
   

- Advertisement -