euglug.org

[Eug-lug] SQL/postgres help on a “cross join” ?

작성자

카테고리:



larry priceFri Apr 28 14:44:24 PDT 2006

To get what you want from straight SQL

I think you end up doing either a bunch of subqueries (one per dept)
or an equally convoluted join.

The syntax bit you are looking for is

select table.column as alias_name

On 4/28/06, Matthew Jarvis <mattj at bikefriday.com> wrote:
> Thanks, but that's not it either.... in fact as far as I can tell it's
> virtually the same results....
>
> Looking for the Dept names from Department table to be columns in the
> result table.....
>
> Am I gonna have to sling some code to get this done?
>
>
> Matthew S. Jarvis
> IT Manager
> Bike Friday - "Performance that Packs."
> www.bikefriday.com
> 541/687-0487 x140
> mattj at bikefriday.com
>
>
> M. Bitner wrote:
> > Something like this maybe?
> >
> > select employee.last_name, employee.first_name, department.name, sum(
> > timeentry.hours) as tot_hrs
> > from timeentry
> > join employee on timeentry.emp_id = employee.emp_id
> > join department on employee.department_id = department.department_id
> > where date( apply_date) > '2006-04-01'
> > group by department.name, employee.last_name, employee.first_name
> > order by employee.last_name, department.name
> >
> _______________________________________________
> EUGLUG mailing list
> euglug at euglug.org
> http://www.euglug.org/mailman/listinfo/euglug
>