Forwarded from Dasturlash hayotiοΈοΈ οΈ
Forwarded from Adam H H
SQLPracticeProblems_SQLServer-1-54.pdf
594.1 KB
Forwarded from Deleted Account
Expert_T_SQL_Window_Functions_in_SQL_Server_2019_The_Hidden_Secret.pdf
9.6 MB
#CHALLANGE
create table Hackers(
hacker_id int,
name nvarchar(99)
)
insert into Hackers values
(5077,'Rose'),
(21283,'Angela'),
(62743,'Frank'),
(88255,'Patrick'),
(96196,'Lisa')
create table Challenges(
challenge_id int,
hacker_id int
)
insert into Challenges values
(61654,5077),
(58302,21283),
(40587,88255),
(29477,5077),
(1220,21283),
(69514, 21283),
(46561,62743),
(58077,62743),
(18483,88255),
(76766,21283),
(52382,5077),
(74467,21283),
(33625,96196),
(26053,88255),
(42665,62743),
(12859,62743),
(70094,21283),
(34599,88255),
(54680,88255),
(61881,5077)
select * from Hackers
select * from Challenges
with AABB as(
select c.hacker_id,h.name,c.nums, ROW_NUMBER() over (partition by c.nums order by c.nums) as son
from (select hacker_id, count(challenge_id) as nums from Challenges group by hacker_id) c
inner join Hackers h
on h.hacker_id=c.hacker_id
)
select hacker_id,name,nums from AABB
where name in (select case
when nums in (select nums from AABB where son>1) and nums=(select max(nums) from AABB) then name
when nums in (select nums from AABB where son>1) and nums!=(select max(nums) from AABB) then null
else name
end
from AABB)
create table Hackers(
hacker_id int,
name nvarchar(99)
)
insert into Hackers values
(5077,'Rose'),
(21283,'Angela'),
(62743,'Frank'),
(88255,'Patrick'),
(96196,'Lisa')
create table Challenges(
challenge_id int,
hacker_id int
)
insert into Challenges values
(61654,5077),
(58302,21283),
(40587,88255),
(29477,5077),
(1220,21283),
(69514, 21283),
(46561,62743),
(58077,62743),
(18483,88255),
(76766,21283),
(52382,5077),
(74467,21283),
(33625,96196),
(26053,88255),
(42665,62743),
(12859,62743),
(70094,21283),
(34599,88255),
(54680,88255),
(61881,5077)
select * from Hackers
select * from Challenges
with AABB as(
select c.hacker_id,h.name,c.nums, ROW_NUMBER() over (partition by c.nums order by c.nums) as son
from (select hacker_id, count(challenge_id) as nums from Challenges group by hacker_id) c
inner join Hackers h
on h.hacker_id=c.hacker_id
)
select hacker_id,name,nums from AABB
where name in (select case
when nums in (select nums from AABB where son>1) and nums=(select max(nums) from AABB) then name
when nums in (select nums from AABB where son>1) and nums!=(select max(nums) from AABB) then null
else name
end
from AABB)
π3
/*TUB SONLAR N GACHA BO'LGAN*/
#include <iostream>
using namespace std;
int main()
{
int a=2,c,f=0,b;
cin>>b;
while(b>=a){
c=a-1;
while(c>1){
if(a%c==0){
f++;
break;
}
else{
c--;}
}
if(f==0){
cout<<a<<" ";
}
else{
f=0;
}
a++;
}
}
#include <iostream>
using namespace std;
int main()
{
int a=2,c,f=0,b;
cin>>b;
while(b>=a){
c=a-1;
while(c>1){
if(a%c==0){
f++;
break;
}
else{
c--;}
}
if(f==0){
cout<<a<<" ";
}
else{
f=0;
}
a++;
}
}
β‘2π―2π1