sql server - Attempting to add a new column in SQL by subtracting a year -



sql server - Attempting to add a new column in SQL by subtracting a year -

noob @ this. cutting point on this. class assignment , professor has not answered emails since thursday. problem trying solve -

"write query subtract 1 year production date of each album , label recorddate , display album title, production date, , record date each entry in table. order results album title."

here table supposed like

here query used (given in class know repeated inserts wanted)...

create table album( album_id char(4) unique not null, album_title varchar(255), album_year year, album_producer varchar(255), primary key(album_id) ); insert album (album_id, album_title, album_year, album_producer) values ('a001', 'awake', '1994', 'east west record'); insert album (album_id, album_title, album_year, album_producer) values ('a002', 'moving pictures', '1981', 'anthem'); insert album (album_id, album_title, album_year, album_producer) values ('a003', 'damage', '2013', 'rca records'); insert album (album_id, album_title, album_year, album_producer) values ('a004', 'continuum', '2006', 'columbia records');

here used start reply question

alter table album add together record_date int; update album set record_date=(album_year-1);

this create new column , gives results want far (have not gotten later part of question). 2 different queries...

so, advice sql experts, accomplish wants have write multiple queries or can done in 1 single query? datatypes okay?

no, not asking sql this. isn't "please homework me". , sorry, has in cap locks because wants way.

andrew tutor hasn't asked add together new column or anything, has asked nowadays info in specific way.

we store info in sql server using specific rules called database normalization rules.

but show info in specific form write select queries select info tables , utilize sorts of functions , methods manipulate info @ run-time , nowadays info in required structure/format/way.

similarly in case requirement not need add together column tutor asked do, violates rules of normalization. need simple select query, show info in required format/way.

the select query simple ....

select [album_title] [album title] ,[album_year] [production date] ,[album_year] - 1 [record date] album order [album_title]

sql sql-server

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -