C++ STL 1. Pair : Syntax : pair <int,char> p1; it creates a pair {2,'c'} like this. pair <int,int> p2; it creates a pair {2,3} like this . Basic Code : #include <bits/stdc++.h> using namespace std; int main() { // cout<<"hello world\n"; pair <int,int> p1 = {1,2}; cout<<p1.first<< " "<< p1.second<<endl; pair <int, pair<int ,char>> p2 = {1,{2,'c'}}; cout<<p2.first<<" "<<p2.second.first<<" "<<p2.second.second<<endl; pair <int,int> arr[] = {{2,3},{4,5},{6,7}}; cout...
Find Users With Valid E-Mails || Leetcode sql solution || Easy solution || Fully-Explained || 💯💯💯✅✅✅🔥🔥🔥
- Get link
- X
- Other Apps
1517. Find Users With Valid E-Mails
Write an SQL query to find the users who have valid emails.
A valid e-mail has a prefix name and a domain where:
- The prefix name is a string that may contain letters (upper or lower case), digits, underscore
'_', period'.', and/or dash'-'. The prefix name must start with a letter. - The domain is
'@leetcode.com'.
Return the result table in any order.
The query result format is in the following example.
Fully-Explained Solution :
To write SQL query for selecting all rows from the Users table where the mail column to match with a regular expression pattern that describes a valid email address with has the domain @leetcode.com.
REGEXP :- It is the sequence of characters that specifies a match pattern in text
Approach :-
The regular expression pattern should contain'^[a-zA-Z][a-zA-Z0-9._-]*@leetcode\\.com'
^: specifies the starting charater of string[a-zA-Z]: matches only one upper or lower case letter in this sequence.[a-zA-Z0-9._-]*: matches zero or more letter of upper or lower case letter, digit, underscore, period, or dash.@leetcode\\.com: matches the string @leetcode.com, where the backslash is used to escape the period character.
Finally, This SQL query returns all rows from the Users table
- the mail column starts with a letter ^[a-zA-Z],
- followed by zero or more occurrences of letters, digits, underscores, periods, or dashes, [a-zA-Z0-9._-]*
- ends with @leetcode.com , '@leetcode\.com'
This satisfies the condition of a valid email address
SQL Query :-
SELECT *
FROM Users
WHERE mail REGEXP '^[a-zA-Z][a-zA-Z0-9._-]*@leetcode\\.com' ;Popular posts from this blog
C++ || STL || standard template libraries
C++ STL 1. Pair : Syntax : pair <int,char> p1; it creates a pair {2,'c'} like this. pair <int,int> p2; it creates a pair {2,3} like this . Basic Code : #include <bits/stdc++.h> using namespace std; int main() { // cout<<"hello world\n"; pair <int,int> p1 = {1,2}; cout<<p1.first<< " "<< p1.second<<endl; pair <int, pair<int ,char>> p2 = {1,{2,'c'}}; cout<<p2.first<<" "<<p2.second.first<<" "<<p2.second.second<<endl; pair <int,int> arr[] = {{2,3},{4,5},{6,7}}; cout...
Power of Millets || Happy And Healthy Life
Foundation Day Meeting : By D. Anjaneyulu Reddy : Power of millets: When food is right no medicine is needed. When food is wrong no medicine works 1. Cosmetologist : due to unbalanced diet, regularly going to cosmetologist 2. Harmonal imbalance : hair loss 3. 1 gm of sugar / 1 litre of blood : It is good for health. 4. Staple food : It is eaten regularly , large part of person's diet. 5. Don't eat icecream as it increase the sugar content in blood. Embrace meaning : include , hug
Sales Analysis III || Leetcode SQL solution || Easy approach || sub-query || 🔥🔥🔥🔥💯💯💯💯✅✅✅✅
1084 . Sales Analysis III Leetcode question : 1084. Sales Analysis III Write an SQL query that reports the products that were only sold in the first quarter of 2019 . That is, between 2019-01-01 and 2019-03-31 inclusive. Return the result table in any order . The query result format is in the following example. SQL SOLUTION : select product_id , product_name from Product where product_id not in ( select p . product_id from Product p left join Sales s on p . product_id = s . product_id where s . sale_date < date ( ' 2019 - 01 - 01 ' ) or s . sale_date > date ( ' 2019 - 03 - 31 ' ) or s . seller_id is null ) ;
Comments
Post a Comment