CASorter
asked on
how to group items with a like clause in MSSQL SP
i have this query result
2 08/29/2016 4X6NOGLOGO528100251
4 08/29/2016 4X8LOGO785329999
1 08/29/2016 5X10LOGO787879999
1 08/29/2016 5X7LOGO5119899LRG
2 08/29/2016 6X6LOGO78279ELK
2 08/29/2016 6X7LOGO50669CORDELL
50 08/29/2016 MG310B
2 08/29/2016 MG310BK
16 08/29/2016 MG310BM
41 08/29/2016 MG310RB
this is what i am trying to get
12 08/29/2016 LOGO
50 08/29/2016 MG310B
2 08/29/2016 MG310BK
16 08/29/2016 MG310BM
41 08/29/2016 MG310RB
here is the query that produces the top part
i am looking for something that will group all the descriptions that are LIKE %LOGO% together in one line
2 08/29/2016 4X6NOGLOGO528100251
4 08/29/2016 4X8LOGO785329999
1 08/29/2016 5X10LOGO787879999
1 08/29/2016 5X7LOGO5119899LRG
2 08/29/2016 6X6LOGO78279ELK
2 08/29/2016 6X7LOGO50669CORDELL
50 08/29/2016 MG310B
2 08/29/2016 MG310BK
16 08/29/2016 MG310BM
41 08/29/2016 MG310RB
this is what i am trying to get
12 08/29/2016 LOGO
50 08/29/2016 MG310B
2 08/29/2016 MG310BK
16 08/29/2016 MG310BM
41 08/29/2016 MG310RB
here is the query that produces the top part
SELECT COUNT(*) AS Expr1, evtDate, Products.ProdExtId
FROM Events INNER JOIN
Items ON Events.EvtItemId = Items.ItmIntId INNER JOIN
EventTypes ON Events.EvtTypeId = EventTypes.EvtTypeIntId INNER JOIN
TouchPoints ON Events.TouchPointId = TouchPoints.TPtIntId AND EventTypes.EvtTypeIntId = TouchPoints.TPtEvtTypeId INNER JOIN
Products ON Items.ItmProdId = Products.ProdIntId
WHERE (Events.EvtTime > @Param3) AND (Events.EvtTime < @Param4) AND (TouchPoints.TPtExtId <> 'plant' AND TouchPoints.TPtExtId <> 'storage')
GROUP BY evtDate, Products.ProdExtId
ORDER BY evtDate, Products.ProdExtId
i am looking for something that will group all the descriptions that are LIKE %LOGO% together in one line
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
well done...
thanks for the quick response... good technique to remember.
thanks for the quick response... good technique to remember.
Open in new window