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
 Help in SQL Statement

Author  Topic 

rekhtar
Starting Member

4 Posts

Posted - 2008-12-24 : 07:11:16
Hi bro.

Actually I am still beginner in SQL, so I need to know what's wrong in this statement:

SELECT Contacts.Company, Telephones.BusinessPhone, Telephones.HomePhone, Telephones.MobilePhone, Telephones.FaxNumber, Contacts.CName, Telephones.Mail, Contacts.JobTitle, Contacts.Street, Contacts.City, Contacts.Country, Contacts.WebPage, Contacts.Notes, Cats.CatName
FROM Cats INNER JOIN (Contacts INNER JOIN Telephones ON Contacts.CID = Telephones.CID) ON Cats.CatID = Contacts.CatID
GROUP BY Contacts.CName

I have 2 tables (Contacts and telephones)
one contact has many telephones
I need to view all telephone numbers related to Contact, group by Contact name (CName column).

Thanks Guys

God loves the person who gives his information to the mankind

bklr
Master Smack Fu Yak Hacker

1693 Posts

Posted - 2008-12-24 : 07:14:50
try like this
SELECT ct.Company, t.BusinessPhone, t.HomePhone, t.MobilePhone, t.FaxNumber, ct.CName, t.Mail, ct.JobTitle, c.Street, ct.City, ct.Country, ct.WebPage, ct.Notes, c.CatName
FROM Cats c
INNER JOIN Contacts ct ON c.CatID = ct.CatID
INNER JOIN Telephones t ON ct.CID = t.CID
GROUP BY ct.CName
Go to Top of Page

rekhtar
Starting Member

4 Posts

Posted - 2008-12-24 : 10:23:10
Thanks for helping but it still not working, there is syntax error(missing operator)

God loves the person who gives his information to the mankind
Go to Top of Page

raky
Aged Yak Warrior

767 Posts

Posted - 2008-12-24 : 10:35:47
Hi,

Please post your complete query which u tried to execute and error message which you got exactly...so that we may help.
Go to Top of Page

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2008-12-24 : 10:57:55
quote:
Originally posted by rekhtar

Hi bro.

Actually I am still beginner in SQL, so I need to know what's wrong in this statement:

SELECT Contacts.Company, Telephones.BusinessPhone, Telephones.HomePhone, Telephones.MobilePhone, Telephones.FaxNumber, Contacts.CName, Telephones.Mail, Contacts.JobTitle, Contacts.Street, Contacts.City, Contacts.Country, Contacts.WebPage, Contacts.Notes, Cats.CatName
FROM Cats INNER JOIN (Contacts INNER JOIN Telephones ON Contacts.CID = Telephones.CID) ON Cats.CatID = Contacts.CatID
GROUP BY Contacts.CName

I have 2 tables (Contacts and telephones)
one contact has many telephones
I need to view all telephone numbers related to Contact, group by Contact name (CName column).

Thanks Guys

God loves the person who gives his information to the mankind



If you only want to group by Ct.Cname,then you have to apply aggregate fundtion(Like Min,Max,Sum) for others.
Go to Top of Page

rekhtar
Starting Member

4 Posts

Posted - 2008-12-25 : 12:26:53
quote:
Originally posted by sodeep

quote:
Originally posted by rekhtar

Hi bro.

Actually I am still beginner in SQL, so I need to know what's wrong in this statement:

SELECT Contacts.Company, Telephones.BusinessPhone, Telephones.HomePhone, Telephones.MobilePhone, Telephones.FaxNumber, Contacts.CName, Telephones.Mail, Contacts.JobTitle, Contacts.Street, Contacts.City, Contacts.Country, Contacts.WebPage, Contacts.Notes, Cats.CatName
FROM Cats INNER JOIN (Contacts INNER JOIN Telephones ON Contacts.CID = Telephones.CID) ON Cats.CatID = Contacts.CatID
GROUP BY Contacts.CName

I have 2 tables (Contacts and telephones)
one contact has many telephones
I need to view all telephone numbers related to Contact, group by Contact name (CName column).

Thanks Guys

God loves the person who gives his information to the mankind



If you only want to group by Ct.Cname,then you have to apply aggregate fundtion(Like Min,Max,Sum) for others.



Actually there is no column must have aggregate function, the really problem is If contact person has 2 mobiles, the query table will display each mobile with the same contact in seperate row

I want to display just names and display (+) next to contact name, and when I want to display his mobiles I press on (+) to show me his mobiles

God loves the person who gives his information to the mankind
Go to Top of Page

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2008-12-25 : 13:35:02
Looks like you are looking for Interactive Drilldown option. Look for Reporting Services.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-12-27 : 12:02:12
quote:
Originally posted by rekhtar

quote:
Originally posted by sodeep

quote:
Originally posted by rekhtar

Hi bro.

Actually I am still beginner in SQL, so I need to know what's wrong in this statement:

SELECT Contacts.Company, Telephones.BusinessPhone, Telephones.HomePhone, Telephones.MobilePhone, Telephones.FaxNumber, Contacts.CName, Telephones.Mail, Contacts.JobTitle, Contacts.Street, Contacts.City, Contacts.Country, Contacts.WebPage, Contacts.Notes, Cats.CatName
FROM Cats INNER JOIN (Contacts INNER JOIN Telephones ON Contacts.CID = Telephones.CID) ON Cats.CatID = Contacts.CatID
GROUP BY Contacts.CName

I have 2 tables (Contacts and telephones)
one contact has many telephones
I need to view all telephone numbers related to Contact, group by Contact name (CName column).

Thanks Guys

God loves the person who gives his information to the mankind



If you only want to group by Ct.Cname,then you have to apply aggregate fundtion(Like Min,Max,Sum) for others.



Actually there is no column must have aggregate function, the really problem is If contact person has 2 mobiles, the query table will display each mobile with the same contact in seperate row

I want to display just names and display (+) next to contact name, and when I want to display his mobiles I press on (+) to show me his mobiles

God loves the person who gives his information to the mankind


whats the front end application you're using?
Go to Top of Page

rekhtar
Starting Member

4 Posts

Posted - 2008-12-27 : 14:50:57
It's VB.NET 2005

God loves the person who gives his information to the mankind
Go to Top of Page
   

- Advertisement -