Home > Software engineering > Access the SQL for help, be urgent!!!!!!!!!!!! Online etc.!!!!!!!!!!!!!!!
Access the SQL for help, be urgent!!!!!!!!!!!! Online etc.!!!!!!!!!!!!!!!
Time:09-30
There is a table: membership card Fields: membership number, card number and issuing date of commissioning date, shop Each member may have more than one card, now want to according to the [shop] listed member card in his hand out to enable the membership card during a long period of the first opening date whether the query term, in order to confirm whether the member is an effective new members, said the possibility of repetitive, main purpose is to statistics each shop in a certain period of new active member, the new definition of active member: all members of the membership card of the earliest opening date for a while during the statistical period,
The SQL beats me, please expert help, be urgent!!!!!!
CodePudding user response:
No database on this machine now, but in general use group by should be yes, try to write basic query statement as follows, with the help of reference:
Date of the SELECT membership number, MIN (enabled) AS to enable the earliest date FROM membership card GROUP BY membership number
CodePudding user response:
For example # # # # # # member store card issuing date enable date Record 1: zhang SAN 1 store a0001 2013/5/2 2015/2/1 Record 2: zhang 3 shop c0033 2015/2/5 9999/12/31 Record three: zhang SAN 2 shop b0008 2013/3/6 2014/3/31 Record 4: li si 1 store a0002 2013/4/5 2015/1/28 Record 5; Two 2 shop b0005 2014/9/10 2015/1/31 Assumes that the extraction of 2014 new members effectively, should be recorded after extracting 3 Extracting new active member 2015, should be recorded after 4, record 5 The SQL should be how to write? Thank you!
CodePudding user response:
Date is to choose to open an account in between the two date, right? Use the select AA from the TABLE where the date between date1 and date2