sql server - Is it possible to create an SQL query that displays results like this? -
background
i have database hold records of assets in office. each asset have condition, category name , age.
a conditionid can be;
in use spare in circulation
categoryid are;
phone pc laptop
and age field called aquireddate holds records like;
2009-04-24 15:07:51.257
example
i've created example of inputs of query explain better need if possible.
nb.
- inputs in orange in above example.
- i've split example 2 separate queries.
- count output
question
is type of query , result set possible using sql alone? , if start? easier use ms excel also?
yes possible, orange fields can e.g.
where categoryid ='phone' , conditionid in ('in use', 'in circulation')
for yellow 1 datediff of days of accuired date , divide 365 , floor value, last 1 (6+ years category) need take minimum of 5 , calculated value 0 between 0-1 year old etc. until 5 has above 6 years.
when group calculated column , select additional count desire.
Comments
Post a Comment