Please explain one phrase in the select:
  total(1) over (partition by city_txt, mode_txt)
Is "total" a function and does "1" refer to city_txt?
I can't wrap my head around what's going on with this phrase.
Doug

> -----Original Message-----
> From: sqlite-users <sqlite-users-boun...@mailinglists.sqlite.org>
> On Behalf Of Keith Medcalf
> Sent: Tuesday, October 22, 2019 7:11 AM
> To: SQLite mailing list <sqlite-users@mailinglists.sqlite.org>
> Subject: Re: [sqlite] Can SQLite do this in a single query?
> 
> CREATE TABLE employees(employee_id, city_id, mode_id);
> CREATE TABLE citys(city_id, city_txt);
> CREATE TABLE modes(mode_id, mode_txt);
> 
>   select city_txt,
>          mode_txt,
>          total(1) over (partition by city_txt, mode_txt) /
> total(1) over (partition by city_txt) as percentage
>     from employees, citys, modes
>    where employees.city_id == citys.city_id
>      and employees.mode_id == modes.mode_id
> group by city_txt, mode_txt
> group by city_txt, mode_txt;
> 
> You have to paint the output table yourself.
> 
> --
> The fact that there's a Highway to Hell but only a Stairway to
> Heaven says a lot about anticipated traffic volume.
> 
> >-----Original Message-----
> >From: sqlite-users <sqlite-users-boun...@mailinglists.sqlite.org>
> On
> >Behalf Of Winfried
> >Sent: Tuesday, 22 October, 2019 07:23
> >To: sqlite-users@mailinglists.sqlite.org
> >Subject: Re: [sqlite] Can SQLite do this in a single query?
> >
> >Yes, I forgot the column mode_id in the Employee's table.
> >
> >Thanks, I'll read up on the features SQLite's SELECT has to
> offer. At
> >worst,
> >I'll just run a simpler query multiple times.
> >
> >https://www.sqlite.org/lang_select.html
> >
> >
> >
> >--
> >Sent from: http://sqlite.1065341.n5.nabble.com/
> >_______________________________________________
> >sqlite-users mailing list
> >sqlite-users@mailinglists.sqlite.org
> >http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-
> users
> 
> 
> 
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-
> users

_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to