SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Help in SQL Statement
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

rekhtar
Starting Member

Egypt
4 Posts

Posted - 12/24/2008 :  07:11:16  Show Profile  Click to see rekhtar's MSN Messenger address  Reply with Quote
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
Flowing Fount of Yak Knowledge

India
1693 Posts

Posted - 12/24/2008 :  07:14:50  Show Profile  Reply with Quote
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

Edited by - bklr on 12/24/2008 07:15:36
Go to Top of Page

rekhtar
Starting Member

Egypt
4 Posts

Posted - 12/24/2008 :  10:23:10  Show Profile  Click to see rekhtar's MSN Messenger address  Reply with Quote
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 - 12/24/2008 :  10:35:47  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

USA
7174 Posts

Posted - 12/24/2008 :  10:57:55  Show Profile  Reply with Quote
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

Egypt
4 Posts

Posted - 12/25/2008 :  12:26:53  Show Profile  Click to see rekhtar's MSN Messenger address  Reply with Quote
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
Flowing Fount of Yak Knowledge

USA
7174 Posts

Posted - 12/25/2008 :  13:35:02  Show Profile  Reply with Quote
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

India
52317 Posts

Posted - 12/27/2008 :  12:02:12  Show Profile  Reply with Quote
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

Egypt
4 Posts

Posted - 12/27/2008 :  14:50:57  Show Profile  Click to see rekhtar's MSN Messenger address  Reply with Quote
It's VB.NET 2005

God loves the person who gives his information to the mankind
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.08 seconds. Powered By: Snitz Forums 2000