I want to revise some relatively simple information in the most efficient way: Using a limited selection of sample data:
CREATE TABLE
(id varchar(30)
,payent_type varchar(30)
,payment_date DATETIME)
INSERT INTO
INSERT INTO
INSERT INTO
INSERT INTO
INSERT INTO
INSERT INTO
INSERT INTO
INSERT INTO
INSERT INTO
INSERT INTO
INSERT INTO
INSERT INTO
INSERT INTO
INSERT INTO
INSERT INTO
And turning it into this:
ID | 2005 | 2006 | 2007 | 2008 | 2009 | 2010
001 | NULL | NULL | regular gift | NULL | Both gifts | NULL
Where, in principle, if the ID has both one and an ordinary gift during the year, then call it “both gifts”, if there is only one gift, then “only gift”, and if there is only an ordinary gift, then “ordinary gift "
This data will then be used as part of another larger request.
It’s very easy for me to handle if the ID ever gave one or the usual (or both) gift, but I try my best to work on it year after year, without creating a series of temporary tables that significantly slow down the work
Thanks in advance:)
EDIT. , : 200 .