-2

Table

For a particular date(as shown in image) where the source is only Android, I want to return the 5th column as true else null using sql

I tried using partition statement to answer the problem, but that seems to give me the same records as rnum

  • Hi, welcome to SO! I would recommend reading through [SO tour page](https://stackoverflow.com/tour) and through SO help center on [how to ask good question](https://stackoverflow.com/help/how-to-ask). After that, try editing this question. Do take care to include [Minimal, Reproducible Example](https://stackoverflow.com/help/minimal-reproducible-example), [tag your RDBMS](https://meta.stackoverflow.com/questions/388759/why-should-i-tag-my-rdbms) and [do not use pictures](https://meta.stackoverflow.com/questions/285551/why-should-i-not-upload-images-of-code-data-errors-when-asking-a-question). – Aarlaneth Oct 31 '22 at 11:33
  • If the "Only Android" column is already filled like in your image, the answer below should do. If not, use NOT EXISTS to check there are no other entries. – Jonas Metzler Oct 31 '22 at 13:29

1 Answers1

0

Try this:

select week_start, user_id, source, rnum, case when [Only android] = 1 then 'true' else null from table_name

Vivek Rahul
  • 314
  • 2
  • 15