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
 Does this query look correct

Author  Topic 

velvettiger
Posting Yak Master

115 Posts

Posted - 2008-10-03 : 11:18:22
Hi Guys,

I am suppose to find:-
Customers who do not have Digicel phone numbers i.e. have a Cable & Wireless number or do not have any cell number at all. Please be sure to check within the fields of home phone, work phone, cell phone and fax phone to determine. Do you guys think that this code is correct


SELECT
distinct c.cardnumber
,FirstName
,LastName
,AddressLine1
,AddressLine2
,AddressLine3
,HomePhone
,CellPhone
,WorkPhone
,CardClass
,c.ClassCode
,CycleCode
,Email
,sum(DailyTransactionValue)TotalSpend

FROM
customer c inner join SubsidiaryByCustomerByClassTransactionDetail ss on c.cardnumber=ss.cardnumber


WHERE CellPhone not LIKE '246256%'
and CellPhone not LIKE '246257%'
and CellPhone not LIKE '246258%'
and CellPhone not LIKE '246259%'
and CellPhone not LIKE '246260%'
and CellPhone not LIKE '246261%'
and CellPhone not LIKE '246262%'
and CellPhone not LIKE '246263%'
and CellPhone not LIKE '246264%'
and CellPhone not LIKE '246265%'
and CellPhone not LIKE '246266%'
and CellPhone not LIKE '246267%'
and CellPhone not LIKE '246268%'
and CellPhone not LIKE '246269%'
and CellPhone not LIKE '246820%'
and CellPhone not LIKE '246821%'
and CellPhone not LIKE '246822%'
and CellPhone not LIKE '246823%'
and CellPhone not LIKE '246824%'
and CellPhone not LIKE '246825%'
and CellPhone not LIKE '246826%'
and CellPhone not LIKE '246827%'
and CellPhone not LIKE '246828%'
and CellPhone not LIKE '246829%'

AND HomePhone not LIKE '246256%'
and HomePhone not LIKE '246257%'
and HomePhone not LIKE '246258%'
and HomePhone not LIKE '246259%'
and HomePhone not LIKE '246260%'
and HomePhone not LIKE '246261%'
and HomePhone not LIKE '246262%'
and HomePhone not LIKE '246263%'
and HomePhone not LIKE '246264%'
and HomePhone not LIKE '246265%'
and HomePhone not LIKE '246266%'
and HomePhone not LIKE '246267%'
and HomePhone not LIKE '246268%'
and HomePhone not LIKE '246269%'
and HomePhone not LIKE '246820%'
and HomePhone not LIKE '246821%'
and HomePhone not LIKE '246822%'
and HomePhone not LIKE '246823%'
and HomePhone not LIKE '246824%'
and HomePhone not LIKE '246825%'
and HomePhone not LIKE '246826%'
and HomePhone not LIKE '246827%'
and HomePhone not LIKE '246828%'
and HomePhone not LIKE '246829%'

and WorkPhone not LIKE '246256%'
and WorkPhone not LIKE '246257%'
and WorkPhone not LIKE '246258%'
and WorkPhone not LIKE '246259%'
and WorkPhone not LIKE '246260%'
and WorkPhone not LIKE '246261%'
and WorkPhone not LIKE '246262%'
and WorkPhone not LIKE '246263%'
and WorkPhone not LIKE '246264%'
and WorkPhone not LIKE '246265%'
and WorkPhone not LIKE '246266%'
and WorkPhone not LIKE '246267%'
and WorkPhone not LIKE '246268%'
and WorkPhone not LIKE '246269%'
and WorkPhone not LIKE '246820%'
and WorkPhone not LIKE '246821%'
and WorkPhone not LIKE '246822%'
and WorkPhone not LIKE '246823%'
and WorkPhone not LIKE '246824%'
and WorkPhone not LIKE '246825%'
and WorkPhone not LIKE '246826%'
and WorkPhone not LIKE '246827%'
and WorkPhone not LIKE '246828%'
and WorkPhone not LIKE '246829%'


and TransactionDate >= '20080201' and TransactionDate < '20080801
group by c.CARDNUMBER
,FirstName
,LastName
,AddressLine1
,AddressLine2
,AddressLine3
,HomePhone
,CellPhone
,WorkPhone
,CardClass
,c.ClassCode
,CycleCode
,Email

order by c.CARDNUMBER

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-10-03 : 11:21:07
whats the significance of these hardcoded values?
Go to Top of Page

velvettiger
Posting Yak Master

115 Posts

Posted - 2008-10-03 : 11:28:23
These hard coded value are the prefixes of those customers with digicel nos so I don't want these customers to show in the list because I want to display cable and wireless customers. I don't know what Cable and wireless numbers begin with so that y I basically said to output customers that dont have digicel numbers
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-10-03 : 11:39:05
quote:
Originally posted by velvettiger

These hard coded value are the prefixes of those customers with digicel nos so I don't want these customers to show in the list because I want to display cable and wireless customers. I don't know what Cable and wireless numbers begin with so that y I basically said to output customers that dont have digicel numbers


no way to generalise digicel nos?
Go to Top of Page

velvettiger
Posting Yak Master

115 Posts

Posted - 2008-10-03 : 11:42:22
No there isnt any way to generalise the digicel nos.
Go to Top of Page
   

- Advertisement -