question

agung_3109 avatar image
agung_3109 asked

please help me finish this query

  • Display Product Id (obtained by replacing ‘PR’ into ‘Product ’ of ProductId), Product Name (obtained from product name in uppercase format), MaterialName, and Average Product Purchased (obtained from average quantity of product purchased) for product which price is more than 20000 and Average Product Purchased is greater than average of all sales transaction quantity.

(alias subquery)

  • Display DistributorName, Distributor Phone (obtained from replace ‘08’ to ‘+628’ on DistributorPhone), DistributorAddress, and PurchaseDate for every distributor whose handle purchase transaction with the most variant product in a purchase transaction.

(alias subquery)

can you give me the query to finish this question please....

ssms
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

WRBI avatar image WRBI commented ·

Please edit your question to include the SQL that you've already wrote and use the CODE button to correctly format it. Please include some sample data as well.

0 Likes 0 ·

1 Answer

·
Jon Crawford avatar image
Jon Crawford answered

You'll have to look up the delimitedSplit8k by Jeff Moden and implement it, or similar function in order to pull this off, but then you can use this to get what you deserve:

SELECT [Query] =REPLACE(STUFF((

SELECT','+char(Item)

FROM dbo.FN_delimitedSplit8k('73,32,99,97,110,110,111,116,32,100,111,32,109,121,32,111,119,110,32,119,111,114,107',',')

FORXMLPATH('')

), 1, 1,''),',','')

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.