Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

How to create this CSV in Sql query?

$
0
0
I have a order_detail table with the primary key order_detail_id and the foregin keys order_id and product_id. Also I have three other fields, A, B and C, to describe the nature of this order detail. A product_id can be existed on different order_id but not in a single order_id (ie no duplicate product_id on a order). What I want the dataset to return is when passing the order_id, it could be single or multiple order_id, the query will give me the order_detail_id in comma seperate string if two or more of the same product_id found on the multiple order_ids and the same value on the other three fields, A, B and C, ie I would like to group by all the order_detail_id in a single row if those conditions are met.  Thanks a million. 

Kahlua


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>