Viewing 7 posts - 1 through 7 (of 7 total)
December 3, 2012 at 6:15 am
select SUM(OrderQty) 'Quantity', convert(varchar,month(OrderDate))+'-'+convert(varchar,YEAR(OrderDate)) as 'Month year'
from table1
group by MONTH(OrderDate),YEAR(OrderDate)
having year(OrderDate) between '2008' and '2011'
December 1, 2011 at 1:08 am
good twister
To get third highest salary
select MAX(salary) from Employees where salary <(select MAX(salary) from Employees
where salary <(select MAX(salary) from Employees))
November 15, 2011 at 7:45 am
change table name as what you have given i have used testtable
November 14, 2011 at 12:56 am
select distinct a.district,c.male as male,b.female as female from testtable a
left join
(select district,count(gender) as female from testtable
group by district,gender
having gender='female'
)b
on b.district=a.district
left join
(select district,count(gender) as male from testtable
group by district,gender
having...
November 14, 2011 at 12:54 am
select distinct a.district,c.male as male,b.female as female from testtable a
left join
(select district,count(gender) as female from testtablec
group by district,gender
having gender='female'
)b
on b.district=a.district
left join
(select district,count(gender) as male from testtablec
group by district,gender
having...
November 14, 2011 at 12:53 am
Viewing 7 posts - 1 through 7 (of 7 total)