Page 1 of 1

nini's noob sql ^_^

Posted: Sun Jun 11, 2006 19:41
by nobile
[syntax="sql"]
use pubs

select t.title as libro, p.pub_name as "casa editora", cast(t.price as numeric(12, 2)) as precio
from titles as t
inner join publishers as p on p.pub_id=t.pub_id
where t.type like 'business'
order by t.price desc

select top 5 e.emp_id as "código", e.fname+' '+e.lname as nombre
from employee as e
order by e.hire_date

select datepart(yy, s.ord_date) as "año", datepart(mm, s.ord_date) as mes, sum(s.qty) as cantidad
from sales as s
group by datepart(yy, s.ord_date), datepart(mm, s.ord_date)
order by datepart(yy, s.ord_date)
[/syntax]

Noticed that the month numbers are the same as the ones available, so I don't have to select which months xD