Is this ms-sql?

|
suricruise1 2022-06-29 19:24:56
For example
Mith
Allen
Ward
Jone
suricruise1 2022-06-29 19:25:44
suricruise1 2022-06-29 19:24:56
For example
Mith
Allen
Ward
Jone

Last new column display this type brother

Paul G. 2022-06-29 19:28:29
Swapnil 2022-06-29 19:13:59
i have updated the answer plz refer below now

But it works only in MySQL > 8.x versions

Paul G. 2022-06-29 19:37:41
Swapnil 2022-06-29 19:10:20
with max_price as
(
Select pro_com,max(pro_price) as price
from item_mast
group by pro_com
)
select a.pro_name, b.price, a.com_name
from company_mast a
join max_price b on a.com_id = b.pro_com

OR

Select DISTINCT pro_name as product_name, max(price) over (partition by a.pro_com) as price, com_name as company
from item_mast a
join company_mast b on a.pro_com = b.com_id

select a.pro_name, b.price, a.com_name
from company_mast a
Bro, it looks like table “company_mast a” has no column “a.pro_name”.

Swapnil 2022-06-29 19:50:20
suricruise1 2022-06-29 19:23:13
In this table one new column add .
In that column values are condition: reference ename column values don’t want to S letter only in that column remaining words will display last new column

Is this ms-sql ?

Swapnil 2022-06-29 20:03:42
suricruise1 2022-06-29 19:23:13
In this table one new column add .
In that column values are condition: reference ename column values don’t want to S letter only in that column remaining words will display last new column

— Step 1
alter table employee add column new_ename varchar;

— Step 2
update employee set new_ename =
trim(replace(ename,’S’,”));

Pavankalyan 2022-06-29 21:50:42
Pavankalyan 2022-06-29 13:11:41
What is the maximum limit in mysql IN() clause?

….. Please respond

Sandip Londhe 2022-06-29 21:51:41
mysql_en-22211.jpg
Anyone can solve this ?
Swapnil 2022-06-29 21:53:29
Pavankalyan 2022-06-29 21:50:42
….. Please respond

There is no as such limit

Swapnil 2022-06-29 21:57:48
Sandip Londhe 2022-06-29 21:51:41
Anyone can solve this ?

1
Select * from messages
where conversarion_id in (
select X.id from
(
Select cast(datetime as date), id, row_number() over (partition by cast(datetime as date),id order by datetime) as rn
from conversations c
) X
where X.rn = 1
)

Sandip Londhe 2022-06-29 21:58:46
Thanks man
Sandip Londhe 2022-06-30 04:40:52
Swapnil 2022-06-29 21:57:48
1
Select * from messages
where conversarion_id in (
select X.id from
(
Select cast(datetime as date), id, row_number() over (partition by cast(datetime as date),id order by datetime) as rn
from conversations c
) X
where X.rn = 1
)

For the second solution, have to change in where clause only , i.e. run =2

Swapnil 2022-06-30 08:30:57
Sandip Londhe 2022-06-30 04:40:52
For the second solution, have to change in where clause only , i.e. run =2

Yes thats correct

suricruise1 2022-06-30 09:12:46
suricruise1 2022-06-29 19:23:13
In this table one new column add .
In that column values are condition: reference ename column values don’t want to S letter only in that column remaining words will display last new column

Got

suricruise1 2022-06-30 09:23:24
mysql_en-22223.jpg

suricruise1 2022-06-30 09:24:32
I got answer in w3school website bro
suricruise1 2022-06-30 09:26:33
mysql_en-22225.jpg

Kiara_Caleb 2022-06-30 09:29:28
*Auto Reply*
You can start earning Bitcoin with our trusted and profitable
Platform πŸ’―fast payments and good rates
Contact Admin now for more information
Kindly

Click on this link
πŸ“©πŸ“©πŸ“©πŸ“©πŸ“©πŸ“©πŸ“©πŸ“©
πŸ‘‡πŸ‘‡πŸ‘‡πŸ‘‡πŸ‘‡πŸ‘‡πŸ‘‡πŸ‘‡Welcome to Alpha Finance, we’re delighted to have you here. Please let us know how we can help you. WhatsApp: 16823373309
Kindly visit our website and signup you can place your investment directly from there www.alphafinance.live
πŸ‘†πŸ‘†πŸ‘†πŸ‘†πŸ‘†πŸ‘†πŸ‘†πŸ‘†πŸ‘†
Clink on the link and contact Admin on how to start earning

suricruise1 2022-06-30 09:48:00
Swapnil 2022-06-29 19:10:20
with max_price as
(
Select pro_com,max(pro_price) as price
from item_mast
group by pro_com
)
select a.pro_name, b.price, a.com_name
from company_mast a
join max_price b on a.com_id = b.pro_com

OR

Select DISTINCT pro_name as product_name, max(price) over (partition by a.pro_com) as price, com_name as company
from item_mast a
join company_mast b on a.pro_com = b.com_id

It’s showing wrong answer bro

suricruise1 2022-06-30 09:50:24
Swapnil 2022-06-29 18:09:46
Select pro_name as product_name, max(price) as price, com_name as company
from item_mast a
join company_mast b on a.pro_com = b.com_id
group by pro_name,com_name

Answer is 6 records
It showing 9 records

suricruise1 2022-06-30 09:54:11
Swapnil 2022-06-29 20:03:42
— Step 1
alter table employee add column new_ename varchar;

— Step 2
update employee set new_ename =
trim(replace(ename,’S’,”));

Is this mySQL answer bro

Swapnil 2022-06-30 10:04:23
suricruise1 2022-06-30 09:54:11
Is this mySQL answer bro

Yes

suricruise1 2022-06-30 10:07:04
mysql_en-22231.jpg
It showing brother
suricruise1 2022-06-30 10:07:26
My sql
Swapnil 2022-06-30 10:08:14
Sorry i had sent for MS-SQL not MySQL
suricruise1 2022-06-30 10:13:57
Swapnil 2022-06-30 10:08:14
Sorry i had sent for MS-SQL not MySQL

Don’t say sorry brother.
Select * , replace(ename,’S’,”) from dummyemp

Swapnil 2022-06-30 10:14:00
suricruise1 2022-06-30 10:07:04
It showing brother

create table employee (ename text);

insert into employee values (‘SAA’),(‘SBB’);

ALTER TABLE employee add column hname text;

update employee set hname=trim(replace(ename,’S’,”));

select * from employee;

Ouput:
ename hname
SAA AA
SBB BB

suricruise1 2022-06-30 10:14:47
mysql_en-22236.jpg
MySQL query
Swapnil 2022-06-30 10:15:12
You have to add trim its important else it will create extra space for the character we have replaced
suricruise1 2022-06-30 10:17:05
Swapnil 2022-06-30 10:15:12
You have to add trim its important else it will create extra space for the character we have replaced

Okay bro

Swapnil 2022-06-30 10:53:22
suricruise1 2022-06-30 09:50:24
Answer is 6 records
It showing 9 records

create table company_mast (com_id int, com_name text);

create table item_mast (pro_id int, pro_name text, pro_price int, pro_com int);

insert into company_mast values (11,’Samsung’);
insert into company_mast values (12,’iBall’);
insert into company_mast values (13,’Epison’);
insert into company_mast values (14,’Zebronics’);
insert into company_mast values (15,’Asus’);
insert into company_mast values (16,’Frontech’);

insert into item_mast values (101,’Motherboard’,3200,15);
insert into item_mast values (102,’Keyboard’,450,16);
insert into item_mast values (103,’ZIP’,250,14);
insert into item_mast values (104,’Speaker’,550,16);
insert into item_mast values (105,’Monitor’,5000,11);
insert into item_mast values (106,’DVD’,900,12);
insert into item_mast values (107,’CD Drive’,800,12);
insert into item_mast values (108,’Printer’,2600,13);
insert into item_mast values (109,’Refill’,350,13);

with max_price as
(
select pro_com, max(pro_price) as price
from item_mast
group by pro_com
order by pro_com
)
select b.pro_name,a.price,c.com_name
from max_price a
join item_mast b on a.pro_com = b.pro_com and a.price = b.pro_price
join company_mast c on b.pro_com = c.com_id
order by a.price desc

Output:
pro_name | price | com_name
————- ——- ———–
Monitor | 5000 | Samsung
Motherboard | 3200 | Asus
Printer | 2600 | Epison
DVD | 900 | iBall
Speaker | 550 | Frontech
ZIP | 250 | Zebronics

suricruise1 2022-06-30 10:58:38
Swapnil 2022-06-30 10:53:22
create table company_mast (com_id int, com_name text);

create table item_mast (pro_id int, pro_name text, pro_price int, pro_com int);

insert into company_mast values (11,’Samsung’);
insert into company_mast values (12,’iBall’);
insert into company_mast values (13,’Epison’);
insert into company_mast values (14,’Zebronics’);
insert into company_mast values (15,’Asus’);
insert into company_mast values (16,’Frontech’);

insert into item_mast values (101,’Motherboard’,3200,15);
insert into item_mast values (102,’Keyboard’,450,16);
insert into item_mast values (103,’ZIP’,250,14);
insert into item_mast values (104,’Speaker’,550,16);
insert into item_mast values (105,’Monitor’,5000,11);
insert into item_mast values (106,’DVD’,900,12);
insert into item_mast values (107,’CD Drive’,800,12);
insert into item_mast values (108,’Printer’,2600,13);
insert into item_mast values (109,’Refill’,350,13);

with max_price as
(
select pro_com, max(pro_price) as price
from item_mast
group by pro_com
order by pro_com
)
select b.pro_name,a.price,c.com_name
from max_price a
join item_mast b on a.pro_com = b.pro_com and a.price = b.pro_price
join company_mast c on b.pro_com = c.com_id
order by a.price desc

Output:
pro_name | price | com_name
————- ——- ———–
Monitor | 5000 | Samsung
Motherboard | 3200 | Asus
Printer | 2600 | Epison
DVD | 900 | iBall
Speaker | 550 | Frontech
ZIP | 250 | Zebronics

I will check bro

suricruise1 2022-06-30 11:38:47
Swapnil 2022-06-30 10:53:22
create table company_mast (com_id int, com_name text);

create table item_mast (pro_id int, pro_name text, pro_price int, pro_com int);

insert into company_mast values (11,’Samsung’);
insert into company_mast values (12,’iBall’);
insert into company_mast values (13,’Epison’);
insert into company_mast values (14,’Zebronics’);
insert into company_mast values (15,’Asus’);
insert into company_mast values (16,’Frontech’);

insert into item_mast values (101,’Motherboard’,3200,15);
insert into item_mast values (102,’Keyboard’,450,16);
insert into item_mast values (103,’ZIP’,250,14);
insert into item_mast values (104,’Speaker’,550,16);
insert into item_mast values (105,’Monitor’,5000,11);
insert into item_mast values (106,’DVD’,900,12);
insert into item_mast values (107,’CD Drive’,800,12);
insert into item_mast values (108,’Printer’,2600,13);
insert into item_mast values (109,’Refill’,350,13);

with max_price as
(
select pro_com, max(pro_price) as price
from item_mast
group by pro_com
order by pro_com
)
select b.pro_name,a.price,c.com_name
from max_price a
join item_mast b on a.pro_com = b.pro_com and a.price = b.pro_price
join company_mast c on b.pro_com = c.com_id
order by a.price desc

Output:
pro_name | price | com_name
————- ——- ———–
Monitor | 5000 | Samsung
Motherboard | 3200 | Asus
Printer | 2600 | Epison
DVD | 900 | iBall
Speaker | 550 | Frontech
ZIP | 250 | Zebronics

πŸ‘ bro

Sandip Londhe 2022-06-30 11:45:53
select i.pro_name,c.com_name, max(i.pro_price) price from company_mast c inner join item_mast i on c.com_id = i.pro_com group by com_name;
Sandip Londhe 2022-06-30 11:47:01
I think no need to use the subquery
|