1
Personal I have a query that returns the number of registered phones in each state,parents and also brings the number of customers who have no phone registered in each state,parents but I would like to bring only those customers who have no phone registered...a query is this:
SELECT s.cState,co.cCountry ,ISNULL(cTelephoneType,'NONE') AS 'Tipo Telefone', COUNT(*) AS 'TOTAL' FROM Customer c
LEFT JOIN CustomerTelephone ct on c.nIDCustomer = ct.nIDCustomer JOIN State s on
c.nIDState = s.nIDState JOIN Country co on co.nIDCountry = s.nIDCountry LEFT JOIN TelephoneType tt on tt.nIDTelephoneType = ct.nIDTelephoneType
GROUP BY s.cState,co.cCountry,cTelephoneType
and the result is for now:
Florida United States NONE 16
Nevada United States NONE 7
Nevada United States Cell Phone 7
Nevada United States Home 2
Nevada United States Work 1
Roma Italia NONE 96
Roma Italia Cell Phone 28
Roma Italia Home 4
Roma Italia Work 3
Rosário Argentina NONE 7
São Paulo Brazil NONE 7
Yucatán Mexico NONE 8
I wish only the 'NONE' records appeared'
That’s exactly what it’s worth... !
– Daniel
Gypsy now I need a query using UNION with this query that brings customers without a phone and with another that brings the number of registered phones per state, parents without using LEFT JOIN have any idea how ? the result would be the same from above...
– Daniel
@Daniel You talk, just unite the result?
– Leonel Sanches da Silva
is want to unite the result of the query that brings the states and parents with registered phone with the second query that you helped me...however I can not use LEFT JOIN...know how ?
– Daniel
@Daniel Editei the answer.
– Leonel Sanches da Silva
beauty vo forehead here
– Daniel
Thanks again Gypsy that’s right
– Daniel
the Gypsy in real I would need another way...I had to uncomment the LEFT JOINS there to bring the result I expected...I needed this result without using LEFT JOIN
– Daniel
@Daniel Why?
– Leonel Sanches da Silva
Let’s go continue this discussão in chat.
– Daniel