SQLTeam.com | Weblogs | Forums

SQL query


#1

Hello,

Can someone please help me in writing mysql query? I am new to SQL.
Basically, I want to retrieve the count of no of messages sent per year, where the sender is one particular person.
We have 3 tables using which I have to retrieve the data.

Please help me.

Thanks
Sandhya


#2

Hi,
This is a MSSQL forum, although the query might be able to use in mysql (in some simple sense). Without any information of the table layout, it will be hard for anyone to help you. With the limited info, I would say you try the following:

select year, count(*) from messages where sender = 'xxx' group by year


#3

Thank you so much for the reply.
I have been given these information for to get the desired result.
Table layout like below (3 tables) Message, Yearlist and userlist. Please help me

Message
Table:ID
displayname
content
status

Yearlist:
Table:ID
Year:

userlist:
Table: ID
Sender:

Regards,
Sandhya


#4

SELECT year,COUNT(1) FROM Message A INNER JOIN Yearlist B ON A.ID=B.ID INNER JOIN userlist C ON A.ID=C.ID
WHERE C.SENDER='sender name'
group by year

Thanks
Paramasivan B