Jump to content

Recommended Posts

How to fetch the "name" FROM programname = "Buy" and description which has maximum words using  GROUP BY??

 

I have 6 columns with thousands of product entries:

Table name : eproducts

Columns : product_id, programname, name, description, clean_modelno

 

Ex. Products Entries:

 

product_id : 5001

programname : argos

name : Toshiba 32RV753B

description : By Toshiba (100 words)

model_number : 32RV753B

price : 549.99

 

product_id : 5002

programname : Buy

name : Toshiba 32 Inch Full HD 1080p Freeview  HD LCD TV

description : Television picture quality: Freeview HD digital (Approx 110 words)

model_number : 32RV753B

price : 499

 

product_id : 5003

programname : Amazon

name : Toshiba 32 Inch Widescreen Full HD 1080p LCD TV

desciption : 66cm Visible LCD  HD Ready Integrated Digital (Approx 90 words)

model_number : 32RV753B

price : 650

 

product_id : 5004

programname : Ebey

name : 2RV753B 32Inch  HD Ready 1080p LC HD Read

description : Toshiba 32RV753 / 32RV753B 32" REGZA RV Serie (Approx 97 words)

model_number : 32RV753B

price : 550

 

When I Group by the products using there model numbers, it gave me the first row as output as all these four products has same model number:

 

SELECT *,  

MAX(price) as max_price,

MIN(price) as min_price,

count(distinct programname) as total_retailers

FROM eproducts as e

WHERE 
GROUP BY model_number

 

 

BUT,

I want to get the "name" FROM programname : Buy and description which has maximum words from all four descriptions.

 

Please suggest me a good and efficient solution.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.