Re: SQl help to build a result with custom aliased bool column

2019-04-08 Thread mariusz
On Mon, 8 Apr 2019 19:21:37 +0530 Arup Rakshit wrote: > Hi, > > Thanks for showing different ways to achieve the goal. So what should > be the optimal way to solve this. I have an composite index using > company_id and feature_id columns for project_features table. there are even more ways for

Re: SQl help to build a result with custom aliased bool column

2019-04-08 Thread Arup Rakshit
Hi, Thanks for showing different ways to achieve the goal. So what should be the optimal way to solve this. I have an composite index using company_id and feature_id columns for project_features table. I do ruby on rails development, where table names are plural always by convention. The table

Re: SQl help to build a result with custom aliased bool column

2019-04-08 Thread mariusz
On Mon, 8 Apr 2019 15:32:36 +0530 Arup Rakshit wrote: hi, > I am still having some bugs. I am getting duplicate in the result set. > > psql (11.0, server 10.5) > Type "help" for help. > > aruprakshit=# select * from features; > id | name > +-- > 1 | f1 > 2 | f2 > 3 | f3 > 4 |

Re: SQl help to build a result with custom aliased bool column

2019-04-08 Thread Arup Rakshit
I am still having some bugs. I am getting duplicate in the result set. psql (11.0, server 10.5) Type "help" for help. aruprakshit=# select * from features; id | name +-- 1 | f1 2 | f2 3 | f3 4 | f4 (4 rows) aruprakshit=# select * from company; id | name +-- 1 | c1

Re: SQl help to build a result with custom aliased bool column

2019-04-08 Thread Arup Rakshit
I knew that will be more compact way. Thanks for showing it. One thing I still would like to handle is that, to make sure the column contains only True/False. But right now sometimes it shows NULL. How can I fix this? id|name|active| --||--| 1|f1 |true | 2|f2 |true | 3|f3 |false

Re: SQl help to build a result with custom aliased bool column

2019-04-08 Thread Szymon LipiƄski
Hey, you could just use SELECT features.id, features.name, company_features.company_id = 1 as active regards, Szymon On Mon, 8 Apr 2019 at 09:55, Arup Rakshit wrote: > I have 2 tables Company and Feature. They are connected via a join table > called CompanyFeature. I wa