Link to home
Start Free TrialLog in
Avatar of newbie27
newbie27Flag for United Kingdom of Great Britain and Northern Ireland

asked on

SQL SYNTAX



Hello Experts,

I have a SQL statement where I want to do a slight change to affect the data being displayed in the CSV file.

Basically, I am trying to send registration details to the third party when the customer accept to recieve the newsletter
from them other i only want to send only GiftcodeID and "Anonymous" text for the rest of the columns

EX:

id       name             addrss             registriondate
=========================================================
1        Anonymous      Anonymous      20-03-1009
2      mike                    london            21-03-2009
3      clinton            mexico            24-03-2009
4      Anonymous      Anonymous      24-03-2009


Please can someone help?

thanks
s
Avatar of newbie27
newbie27
Flag of United Kingdom of Great Britain and Northern Ireland image

ASKER

Please see the query attached

SELECT DISTINCT 
                      TOP (100) PERCENT dbo.GiftCertificate.GiftCodeID, dbo.GiftCertificate.CustID, dbo.GiftCertificate.CertRegTitle, dbo.GiftCertificate.CertRegFirstName, 
                      dbo.GiftCertificate.CertRegLastName, dbo.GiftCertificate.CertRegAddr1, dbo.GiftCertificate.CertRegAddr2, dbo.GiftCertificate.CertRegAddr3, 
                      dbo.GiftCertificate.CertRegCity, dbo.GiftCertificate.CertRegCounty, dbo.GiftCertificate.CertRegPostCode,  
                      dbo.Country.CountryName, dbo.GiftCertificateHistory.GiftHistDateAdded AS DateReg
FROM         dbo.GiftCertificate INNER JOIN
                      dbo.GiftCertificateHistory ON dbo.GiftCertificate.GiftCodeID = dbo.GiftCertificateHistory.GiftCodeID INNER JOIN
                      dbo.Country ON dbo.GiftCertificate.CertRegCountryID = dbo.Country.CountryID INNER JOIN
						BritishWildlife on giftcertificate.giftcodeid = BritishWildlife.giftcodeid	
 
WHERE     (dbo.GiftCertificate.GiftCodeID IN
                          (SELECT     GiftCodeID
                            FROM          dbo.GiftCertificateHistory AS GiftCertificateHistory_1
                            WHERE      (StatusID = 'REGISTERED'))) AND 
 
 (dbo.GiftCertificate.CurrentStatusID <> 'LIVE') AND 
                      (dbo.GiftCertificateHistory.StatusID = 'REGISTERED') 
AND (dbo.GiftCertificate.CurrentStatusID <> 'CERT_CANCELLED')
AND dbo.GiftCertificate.GiftCertificateTypeID='WILDLIFE'
 AND dbo.GiftCertificateHistory.GiftHistDateAdded > '2009-03-01'
    AND dbo.GiftCertificateHistory.GiftHistDateAdded < '2009-03-31 23:59'
and BritishWildlife.newsletter=1
ORDER BY dbo.GiftCertificate.GiftCodeID

Open in new window

If  BritishWildlife.newsletter=1 means the customer has opted in otherwise if its  BritishWildlife.newsletter=0 then no details should be sent, so the data should read as "Anonymous"

Please advise
thanks for any help
ASKER CERTIFIED SOLUTION
Avatar of amazingwolf1
amazingwolf1

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
thanks for the help, that was exactly how i wanted it to show...

regards
s