I have data like this but I need to show data if user = 'L001' then show only data of row 1,3,4 and if user = 'L002' then show only data of row 2 & 5, how to create a select query? (with no declare variable)
I have data like this but I need to show data if user = 'L001' then show only data of row 1,3,4 and if user = 'L002' then show only data of row 2 & 5, how to create a select query? (with no declare variable)
1条答案
按热度按时间9vw9lbht1#
Not sure what you mean by with no declare variable but, in my opinion, you can use recursive CTE to create a hierarchy. Everything depends on the complexity of your data because your example is too short and you can use simple
union
for select what you need. Anyway, this is just one of many examples how to organaze it.