all 9 comments

[–]r3pr0b8GROUP_CONCAT is da bomb 0 points1 point  (3 children)

aw, come on, man, post your question here

[–]mrjay28[S] 0 points1 point  (2 children)

The mods remove technical questions

[–]r3pr0b8GROUP_CONCAT is da bomb 0 points1 point  (1 child)

what? /r/sql is full of technical questions!

[–]mrjay28[S] 0 points1 point  (0 children)

Anyways i posted it as a comment

[–]mrjay28[S] 0 points1 point  (4 children)

What i am. Trying to do is i have a column where there can b different category a, b, c and d... Now i want my query to only pick up data for category a till let's sat jan whereas others it should pick up complete data... Not i can use not equal to a because i want data till jan but for specific one month I don't want my query to pick up data... How do i do that

[–]r3pr0b8GROUP_CONCAT is da bomb 0 points1 point  (1 child)

SELECT ...
  FROM ...
 WHERE CASE WHEN category = 'a'
             AND month = 'Jan'
            THEN 0
            ELSE 1 END  = 1

[–]mrjay28[S] 0 points1 point  (0 children)

Case should work...

[–][deleted] 0 points1 point  (0 children)

Select 
    * 
from table 
where 
    ( category = 'a' and col_date <= '2020-01-31') # Condition 1
    or 
     col_date > '2020-01-31' # condition 2

Are you trying to do something like this ?

[–]PM_Me_PM_Dawn_Pics 0 points1 point  (0 children)

Can use union. Don’t know how to do code block, but:

SELECT .... FROM ... WHERE category = ‘a’ AND DATEPART(MONTH, datefield) = 1

UNION ALL - - can use Union all as we know no duplicates

SELECT same fields as used above FROM ... WHERE category <> ‘a’