SQL beginners
174 subscribers
76 photos
2 videos
5 files
19 links
Download Telegram
--------Burhon Baqoyev, [7/15/2022 5:38 AM]
SELECT empid, DATEADD(dd, N, '2016-12-06') AS [DAY]
FROM HR.Employees CROSS JOIN Nums
WHERE n BETWEEN 0 AND 4
ORDER BY empid;

------Burhon Baqoyev, [7/15/2022 5:39 AM]
SELECT empid,
DATEADD(DAY, n, '2016-06-11') as dt
FROM HR.Employees,
(
SELECT TOP 5 n
FROM dbo.Nums
) as ndbo
ORDER BY empid
Loyihani to'liq tugatish vazifasi junior dasturchilarga berilganda 😂

👉 @Dasturlash_hayoti
Rank va DensRank
Top N- salaryni topish densrank qo'llanilishiga misol
#window fuction turlari
#include <iostream>
#include <cmath>
using namespace std;

int main()
{
int a,j=0,c;
cin>>a;
c=a-1;
while(c>1){
if(a%c==0){
break;
}
else{
j++;
c--;
}
}
if(j==a-2){
cout<<a<<" Tub son ekan";
}
else{
cout<<"Tub son emas";
}
} Tub son yoki yo'qligini aniqlash
#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)
👍3