Hi Clemens!

Hmm. Let's see how this fits into the bigger picture:

I have a table "categories". I'm doing a select for each of its id:s i.e:

SELECT id FROM categories;


Now, what I want to do is that I want to do two separate subselects that
use categories.id for the respective row the categories select is at, as
input.

So something like

SELECT
id,
(SELECT thing FROM othertable WHERE othertable.something = categories.id)
AS a,
(SELECT thing2 FROM othertable2 WHERE othertable2.something2 = categories.id)
AS b,
a / b AS c
FROM categories ORDER BY c;


Is there any way whatsoever to do this?

Thanks,
Mikael

2013/7/20 Clemens Ladisch <clem...@ladisch.de>

> Mikael wrote:
> > Is anything like "select 7 as a, 8 as b, a / b as c;" possible?
>
> Not directy, but you could use a subquery:
>
>   SELECT *, a / b AS c FROM (SELECT 7 AS a, 8 AS b);
>
>
> Regards,
> Clemens
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to