SQLize
Online
/
PHPize Online
/
SQLtest Online
A
A
A
Share
Donate
Blog
Popular
Donate
A
A
A
Share
Blog
Popular
SQLize.online is a free online SQL environment for quickly running, experimenting with and sharing code.
You can run your SQL code on top of the most popular RDBMS including MySQL, MariaDB, SQLite, PostgreSQL, Oracle and Microsoft SQL Server.
SQL code:
Upload
Copy
Format
Clear
select SubscriberKey, EmailAddress, firstname, lastname, FacilityID, SubscriptionFacilityName, IsActiveFacility, OffersFresh, OffersPackage, OffersPersonal, Email_OptIn, PhoneNumber, SMS_OptIn, SMS_Locale, RefreshDate, Segment from ( select SubscriberKey, EmailAddress, firstname, lastname, FacilityID, SubscriptionFacilityName, IsActiveFacility, OffersFresh, OffersPackage, OffersPersonal, Email_OptIn, PhoneNumber, SMS_OptIn, SMS_Locale, RefreshDate, Segment, row_number() over (partition by EmailAddress order by Segment) as rnk from ( select SubscriberKey, EmailAddress, firstname, lastname, t1.FacilityID, f.SubscriptionFacilityName, f.inmatesearchableflag as IsActiveFacility, f.OffersFreshCategoryFlag as OffersFresh, f.OffersPackageCategoryFlag as OffersPackage, f.OffersPersonalCareCategoryFlag as OffersPersonal, Email_OptIn, PhoneNumber, SMS_OptIn, SMS_Locale, RefreshDate, Segment from ( select c.ID as SubscriberKey, c.email as EmailAddress, c.firstname, c.lastname, case when c.MC_iCare_Facility_Shortname__c is null and o.Facility is not null then o.Facility else c.MC_iCare_Facility_Shortname__c end as FacilityID, c.MC_Email_Subscription_Status__c as Email_OptIn, c.MC_SMS_Phone_Number__c as PhoneNumber, c.MC_SMS_Subscription_Status__c as SMS_OptIn, 'en-us' as SMS_Locale, GetDate() as RefreshDate, 'A' as Segment from Contact_Salesforce_1 c left join iCareUS_Facilities f on c.MC_iCare_Facility_Shortname__c = f.storeid left join iCareUS_Orders o on lower(c.email) = lower(o.Customer_Email_Address) where c.MC_sync_to_iCaremkt__c = 1 and c.MC_Email_Subscription_Status__c = 1 and c.email is not null ) t1 left join iCareUS_Facilities f on t1.FacilityID = f.storeid left join iCareUS_Product_Catalog p on f.storeid = p.FacilityList where f.inmatesearchableflag = 1 and upper(p.ProductName) LIKE 'Slam Dunk Snacks' UNION select SubscriberKey, EmailAddress, firstname, lastname, t1.FacilityID, f.SubscriptionFacilityName, f.inmatesearchableflag as IsActiveFacility, f.OffersFreshCategoryFlag as OffersFresh, f.OffersPackageCategoryFlag as OffersPackage, f.OffersPersonalCareCategoryFlag as OffersPersonal, Email_OptIn, PhoneNumber, SMS_OptIn, SMS_Locale, RefreshDate, Segment from ( select c.ID as SubscriberKey, c.email as EmailAddress, c.firstname, c.lastname, case when c.MC_iCare_Facility_Shortname__c is null and o.Facility is not null then o.Facility else c.MC_iCare_Facility_Shortname__c end as FacilityID, c.MC_Email_Subscription_Status__c as Email_OptIn, c.MC_SMS_Phone_Number__c as PhoneNumber, c.MC_SMS_Subscription_Status__c as SMS_OptIn, 'en-us' as SMS_Locale, GetDate() as RefreshDate, 'B' as Segment from Contact_Salesforce_1 c left join iCareUS_Facilities f on c.MC_iCare_Facility_Shortname__c = f.storeid left join iCareUS_Orders o on lower(c.email) = lower(o.Customer_Email_Address) where c.MC_sync_to_iCaremkt__c = 1 and c.MC_Email_Subscription_Status__c = 1 and c.email is not null ) t1 left join iCareUS_Facilities f on t1.FacilityID = f.storeid left join iCareUS_Product_Catalog p on f.storeid = p.FacilityList where f.inmatesearchableflag = 1 and f.OffersPackageCategoryFlag = 1 UNION select SubscriberKey, EmailAddress, firstname, lastname, t1.FacilityID, f.SubscriptionFacilityName, f.inmatesearchableflag as IsActiveFacility, f.OffersFreshCategoryFlag as OffersFresh, f.OffersPackageCategoryFlag as OffersPackage, f.OffersPersonalCareCategoryFlag as OffersPersonal, Email_OptIn, PhoneNumber, SMS_OptIn, SMS_Locale, RefreshDate, Segment from ( select c.ID as SubscriberKey, c.email as EmailAddress, c.firstname, c.lastname, case when c.MC_iCare_Facility_Shortname__c is null and o.Facility is not null then o.Facility else c.MC_iCare_Facility_Shortname__c end as FacilityID, c.MC_Email_Subscription_Status__c as Email_OptIn, c.MC_SMS_Phone_Number__c as PhoneNumber, c.MC_SMS_Subscription_Status__c as SMS_OptIn, 'en-us' as SMS_Locale, GetDate() as RefreshDate, 'C' as Segment from Contact_Salesforce_1 c left join iCareUS_Facilities f on c.MC_iCare_Facility_Shortname__c = f.storeid left join iCareUS_Orders o on lower(c.email) = lower(o.Customer_Email_Address) where c.MC_sync_to_iCaremkt__c = 1 and c.MC_Email_Subscription_Status__c = 1 and c.email is not null ) t1 left join iCareUS_Facilities f on t1.FacilityID = f.storeid left join iCareUS_Product_Catalog p on f.storeid = p.FacilityList where f.inmatesearchableflag = 1 and f.OffersFreshCategoryFlag = 1 ) x ) y where rnk = 1 and exists (select a.SubscriberKey from [A00 90 Days] a where a.SubscriberKey = y.SubscriberKey)
SQL
Server:
MariaDB 11.4
MariaDB 11.5
MariaDB 10
MariaDB 10 Sakila (ReadOnly)
MySQL 5.7
MySQL 5.7 Sakila (ReadOnly)
MySQL 8.0
MySQL 8.0 Sakila (ReadOnly)
SQLite 3
SQLite 3 Preloaded
PostgreSQL 10 Bookings (ReadOnly)
PostgreSQL 11
PostgreSQL 12
PostgreSQL 13
PostgreSQL 14
PostgreSQL 15
MS SQL Server 2017
MS SQL Server 2019
MS SQL Server 2022
MS SQL Server 2022 AdventureWorks (ReadOnly)
Firebird 4.0
Firebird 4.0 (Employee)
Oracle Database 19c (HR)
Oracle Database 21c
Oracle Database 23c Free
SOQOL
Version
ER Diagram
Preserve result
Stuck with a problem?
Got Error?
Ask ChatGPT!
Result:
Copy
Clear