Select people who didn't renew their license registration

Say i have to generate a report to show the people who didn't renew their license registration , renew of license registration must be every year , i want to select by the date of last renew which might be before more than 2 or 3 years.
I want to except the people who renew their license this year ...
thanks in advance..
SELECT DISTINCT ent.entre_name ,activity_desc , Firm_name , neighbor, street_name , unit_neighbor ,
ISNULL(CONCAT(ISNULL(front_panel_height,0) ,' X ', ISNULL(front_panel_width,0)),'non') AS 'front_panel',
ISNULL(CONCAT(ISNULL(side_panel_height,0) ,' X ', ISNULL(side_panel_width,0)),'non') AS 'side_bullet',
CONVERT(VARCHAR(10),registering_date,111) AS 'registering_date',
CONVERT(VARCHAR(10),expired_license_date,111) AS 'expired_license_date' ,
ISNULL(charge_differs,0) AS 'charge_differs' , MAX(fin_amt) AS 'fin_amt', licop.operation_no
FROM entrepreneur AS ent
INNER JOIN Firm_info AS firm
ON ent.entre_ID = firm.entre_ID
INNER JOIN Section AS sec
ON firm.Section_ID = sec.Section_id
INNER JOIN license AS lic
ON firm.firm_no = lic.firm_no
INNER JOIN license_operations AS licop
ON lic.license_serial = licop.license_serial
INNER JOIN license_charges AS licha
ON licop.operation_no = licha.operation_no
INNER JOIN charges AS cha
ON cha.charge_Id = licha.charge_id
INNER JOIN activities AS acts
ON firm.activity_type = acts.activity_no
WHERE sec.Section_id = @section_no
AND YEAR(SYSDATETIME()) > ( SELECT YEAR(MAX(expired_license_date))
FROM entrepreneur AS inner_ent INNER JOIN Firm_info AS inner_firm
ON inner_ent.entre_ID = inner_firm.entre_ID
INNER JOIN Section AS inner_sec
ON inner_firm.Section_ID = inner_sec.Section_id
INNER JOIN license AS inner_lic
ON inner_firm.firm_no = inner_lic.firm_no
INNER JOIN license_operations AS inner_licop
ON inner_lic.license_serial = inner_licop.license_serial
WHERE sec.Section_id = @section_no
AND YEAR(SYSDATETIME()) > YEAR(expired_license_date)
GROUP BY ent.entre_name , activity_desc , Firm_name , neighbor,
street_name , unit_neighbor , front_panel_height, front_panel_width, side_panel_height,
side_panel_width, registering_date , expired_license_date , charge_differs , licop.operation_no
HAVING YEAR(SYSDATETIME()) > YEAR(MAX(expired_license_date))

;with cte as (select P.*, L.RegistrationDate
from People P CROSS APPLY (select top (1) * from LicenseRegistration LR
where LR.PersonID = P.PersonID order by RegistrationDate DESC) L)
select * from cte where RegistrationDate < dateadd(year, -2, CURRENT_TIMESTAMP)
Please provide structures of your tables and some input and desired output for better answer. This is a solution based on your problem's description.
For every expert, there is an equal and opposite expert. - Becker's Law
My blog
My TechNet articles

Similar Messages

  • I recently bought an iphone 4s from people who are not in the know and restore my iphone .. Now do not be in use for not having ID and password ... Owner apple owner just gave me a serial number how do I want to continue to use this ... Their telephone he

    I recently bought an iphone 4s from people who are not in the know
    and restore my iphone .. Now do not be in use for not having ID and password ... Owner apple owner just gave me a serial number how do I want to continue to use this ... Their telephone help me: (

    I am having same problem . i can not use the phone. my Carrier ROGERS checked the phone its not stolen or lost phone but after restoring always ask for apple ID of previous owner and seller is not responding to any mails or phone if some one can help me out than it will be great.
    thank you

  • People who cannot update their Nokia n97 to firmwa...

    People who cannot update their Nokia n97 to firmware v21.0.045 please post your comments here, provide your product code and whether  your phone is unbranded or not.
    Nokia has stated that the new firmware (v21.0.045) will be available at 08:00 GMT for "standard non-customised versions of the software , with country (SIM-free) and operator versions following over the next few days and weeks." *This can take up to a month for the firmware to be approved by your Operator*
    BUT if you still cannot update your n97 by the stated period of time please post your comments here. Also post here if your unbranded phone is incapable of updating
    Message Edited by St3ph3n on 01-Feb-2010 08:36 PM
    n97.

    @Shqipe...Wrong...I got mine from NOKIA and is not branded and I'm still on the V12 since last year.
    So, we don't any RED Carpet treatment here.....we get......go back to the end of the line treatment for paying in advance and for getting it direct from NOKIA.
    Message Edited by ecoN97 on 01-Feb-2010 10:22 AM
    Message Edited by ecoN97 on 01-Feb-2010 10:24 AM
    Black N-97 V.22.0.110 CV.22.0.110.238.04 -Rm-505Code : 0586701Direct from NOKIA warehouse.
    NOKIA - no more LEMON N97.!! ( Android) is Plan for JAN2011

  • I can't send iMessage to some people who I used to be able to, prior to iOS7 upgrade.

    I can't send iMessage to some people who I used to be able to, prior to iOS7 upgrade. I'm sure these people are still using iPhones. Is there something to do with my settings? Or theirs?

    I got my problem solved but I'm not sure what solved it. I DFU mode my iPhone and then restarted it, the other person only restarted it and now we can iMessage normally. Recently I had the same issue with a new contact but the next day got solved but I didn't do anything.
    I hope this gives you some answers insetad of more questions =S...
    Regards.

  • Hello sir Every time I do the process of registration in Mogah Apple Store and the period and the period of the account is lost I do not know what the problem is there are people who enter into my account and change email We ask God to help you have an ac

    Hello sir Every time I do the process of registration in Mogah Apple Store and the period and the period of the account is lost I do not know what the problem is there are people who enter into my account and change email We ask God to help you have an account I can not restore it the way I do not know where and I do not speak English Aalit Aalit help me I'm in a state of panic for your reply eagerly awaited
    This old Emily Hope you reply and help me [email protected]

    For what it's worth, you posted this in 2011, and here in 2014 I am still having this same issue. Over the last two days, I have had to unlock my apple account 8 times. I didn't get any new devices. I haven't initiated a password reset. I didn't forget my password. I set up two factor authentication and have been able to do the unlocking with the key and using a code sent to one of my devices. 
    That all works.
    It's this having to unlock my account every time I go to use any of my devices. And I have many: iMac, iPad, iPad2, iPad mini, iPhone 5s, iPod touch (daughter), and my old iPhone 4 being used as an ipod touch now.  They are all synced, and all was working just fine.
    I have initiated an incident with Apple (again) but I know they are just going to suggest I change my Apple ID. It's a simple one, and one that I am sure others think is theirs. I don't want to change it. I shouldn't have to. Apple should be able to tell me who is trying to use it, or at least from where.
    Thanks for listening,
    Melissa

  • Who didn't have any battery problem?

    I know so many people who have had battery problems with their ipods it's just unbelievable !!! I am so angry about mine . It 's just 10 months old with a battery life of just one hour only and Apple just sent it back to me saying they didn't find any trouble with it!!! WHAT CAN I DO ?

    Hi,
    Please let us know what is your scanner, what is the operating system of your machine ? Can you see something like this (from the right corner):
    if Yes, just right click and enable it.
    Regards.
    BH
    **Click the KUDOS thumb up on the left to say 'Thanks'**
    Make it easier for other people to find solutions by marking a Reply 'Accept as Solution' if it solves your problem.

  • Can't SMS people who have gone overseas and then come back - weird!!!!!!

    I have a problem with my texts when OTHER people go overseas. When they come back from overseas they can text me but I can't return their text. This has happened 3 times now with 3 different people. I have tried deleting and adding their number and entire contact again, added and deleted the +61 before their number.
    One of the people's text came to me from their @icoud name but they were actually sending it from their phone and the phone setting said they had sent it from their actual telephone number.
    When i tried to reply it bounced back but when I returned text to their @icloud address it went through as a normal text and ended up their conversation thread from me.
    As I mentioned its only happened to people who have been overseas and then come back to Australia.
    Very confusing - any ideas anyone.
    thanks Craig

    Sorry it took me so long to write back, But unfortunately this didn't help my issue.
    My uncle and I did a lot of tests on this computer and have narrowed down the location of the problem a little bit.
    We tried to first reset the SMC and the NVRAM as suggested, but the only thing that did was make the fans run on full tilt for the first session after restarting it for some reason. After that we tried re installing OSX over the OSX that was already on the system (not removing any of the files). This also didn't do anything but make refit stop working. Then we moved onto the next task at hand by removing the hard drive entirely and booting it as an external drive from one of the USB ports... as long as you booted it with the options key held down, it worked perfectly fine. Then we put an alternative hard drive into the computer and installed OSX on that. This time there was no trouble booting anything up. Everything seemed to work flawlessly. So we made a backup of my original drive (OSX, Windows, and all) onto an external hard drive and tested booting to it via USB. That again worked perfectly fine and booted right up with no problems. So after that we formatted the original hard drive and reinstated OSX. We then proceeded to transfer all the old files from the backup onto this new installation and LOW AND BEHOLD..... we were back to square one with it refusing to recognize the hard drive again.
    So this basically told us that there appears to be something either wrong with the hard drive, or something got really screwed up in the software along the lines and by me copying all my old files back over, I just ended up bringing the screwed up file back over with it! (despite not copying over any settings of any kind) So I am still extremely confused as to what is going wrong... did some boot sector possibly get screwed up may be?

  • "Up-selling" "People who looked at x also looked at..."

    "People who looked at x also looked at y"
    I'm getting a request from sales to do this sort of
    up-selling on the site.
    What's the best strategy?
    Thanks

    :) That's funny. :)
    That actually sounds about right.
    The next questions is what could be done that isn't quite so
    aggressive
    a project? This is somewhat rhetorical but if you feel like
    answer,
    please do. Thanks.
    I'm thinking another way to go would be to track by category.
    In other
    words, "You searched for ..... we recommend these other
    products from
    the same category.
    Thanks for your answer.
    darrel wrote:
    >> I didn't get a reply to this. Anyone have any ideas
    what the general
    >> strategy is for this sort of request?
    >>
    >> It's the sort of thing you see on Amazon and I'm
    sure that's why people in
    >> my sales department are requesting it.
    >
    > Well, strategy would likely involve getting a budget put
    together to hire a
    > team of folks to develop said functionality.
    >
    > You'll want marketing folks, sales folks, db admins, web
    designers,
    > usability folks, etc.
    >
    > To actually implement such a thing, you'll need to start
    tracking the
    > browsing habits of your site users, develop database
    tables to store the
    > information, create algorhythms and queries to plow
    through the data and
    > then tie said data back to individual products that
    people may be looking
    > at. You'll likely want to get a lawyer involved as well
    to update the TOS to
    > make sure folks understand what information is being
    tracked about their
    > browsing habits.
    >
    > -Darrel
    >
    >

  • I have a 3 year old MacBook Pro with MAC OSX 10.6.8, iPhoto '09 version 8.1.2 and have downloaded two software programs: one is Aperture 3.2 and the other is Photoshop Elements 9 (which I got from a friend who didn't need it). I am totally happy with the

    I have a 3 year old MacBook Pro with MAC OSX 10.6.8, iPhoto ’09 version 8.1.2 and have downloaded two software programs: one is Aperture 3.2 and the other is Photoshop Elements 9 (which I got from a friend who didn’t need it).
    I am totally happy with the way iPhoto organizes my photos and how I can work with iMovie to create slide shows with music from iTunes, etc.
    I have been shooting mostly high resolution jpegs and I continue to learn more and more about photography, post processing etc. I realize that the small adjustments I can make in iPhoto are good, and are adequate most of the time. However, a have started to experiment with shooting RAW images and would like to go the next step, ie. post processing.I am totally technically challenged and need SIMPLE, INTUITIVE programs and am certainly NOT anywhere ready for Photoshop CS whatever!
    After having these programs sit on my computer, I decided to try to see if I could figure them out. When I opened Aperture, this is what first comes up.
    “Welcome to Aperture 3.2
    Your library needs to be upgraded to work with this version of Aperture. Once upgraded, you will not be able to use this library with previous versions of Aperture.
    Upgrading a library from previous versions of Aperture 3 generally takes a few minutes or less, though larger libraries will take longer. After that, Aperture 3.2 will upgrade your library's thumbnails, but you can use the application during that time.
    Tip: To open a different library, quit Aperture and hold the Option key down while starting Aperture
    Current Library Location:
    Jadzia (home)   -----Pictures------Aperture Library
                                                      QUIT             UPGRADE”
    I have heard horror stories  about moving your entire library to Aperture, ending up with 2 libraries, etc. etc. hence my previous reluctance in attempting Aperture. In addition, many of my photography friends are saying: Go with Lightroom 3.....you’ll love it!
    So here is my dilemma.  I don’t want to mess around with my iPhoto library. All I want to be able to do, is to isolate a few photos, export them to Aperture, Elements, and work on them there, then bring them back into iPhoto.
    Can I do this? Should I forget about Aperture and Elements and look at purchasing yet another program like Lightroom?

    Export those few photos via the File ➙ Export ➙ File Export menu option with Kind = Original to the Desktop.  Then import them into the Aperture library. That would keep one copy in your iPhoto library and another in your Aperture library to edit, etc.
    You can use Photoshop Elements 9 from within iPhoto as your editor of choice. However, if you edit a raw file in iPhoto with PSE9 the resulting edited version must be saved outside the iPhoto Library and imported back in as a new file.  For editing jpegs just do a Save (not a Save As) and it all will be kept within iPhoto. 
    Using Photoshop or Photoshop Elements as Your Editor of Choice in iPhoto.
    1 - select Photoshop or Photoshop Elememts as your editor of choice in iPhoto's General Preference Section's under the "Edit photo:" menu.
    2 - double click on the thumbnail in iPhoto to open it in Photoshop.  When you're finished editing click on the Save button. If you immediately get the JPEG Options window make your selection (Baseline standard seems to be the most compatible jpeg format) and click on the OK button. Your done. 
    3 - however, if you get the navigation window
    that indicates that  PS wants to save it as a PS formatted file.  You'll need to either select JPEG from the menu and save (top image) or click on the desktop in the Navigation window (bottom image) and save it to the desktop for importing as a new photo.
    This method will let iPhoto know that the photo has been editied and will update the thumbnail file to reflect the edit..
    NOTE: With Photoshop Elements  the Saving File preferences should be configured as shown:
    I also suggest the Maximize PSD File Compatabilty be set to Always.  In PSE’s General preference pane set the Color Picker to Apple as shown:
    Note:  to switch between iPhoto and PS or PSE as the editor of choice Control (right)-click on the thumbnail and select either Edit in iPhoto or Edit in External Editor from the contextual menu. If you use iPhoto to edit more than PSE re-select iPhoto in the iPhoto General preference pane. Then iPhoto will be the default editor and you can use the contextual menu to select PSE for your editor when desired.
    OT

  • I would like to know, does Apple Product Giveaways have a page for competitions on Facebook? A lot of People including myself have entered in these competitions and have won and iPhone and many other items. I am one of those people who won, it is true.

    Hi, My name is Sue Keeffe Ayton, I just want to know, does Apple Product Giveaways have a page on Facebook? They are running competition to win Apple Products. A lot of people seem to be winning Apple Products including myself. I saw that I have won a White Iphone 5s 32 GB, I would like to know if this is a scam. If someone goes on the facebook website and type in Apple Product Giveaways you will find this competition page. Please tell me if this page is for real.
    Please I need to know if this is for real.
    A lot of poeple including myself have entered these competitions and have won. I have tried to contact this page admin, but was unable to. I have even tried to contact Facebook team to find out, but was unsuccessful at this point in time.
    I am not sure if these people who are running these competitions are going to send these items out to the winners. I hope they do. If you enter a competition/s and you win, you would expect to receive your winning item/s.
    I never thought it was possible to win something on Facebook. When I saw my name pop up on the winners list in Apple Product Giveaways for March 2 2014 I was excited. I am one of 5 people who won an Apple product.
    Below you will see Apple Product Giveaway page on Facebook. On the right you will see the competition winners. I hope someone can help me find out the truth and if its fake, I will report this to Facebook to have this page shut down. A lot of people will be hurt, disappointed and very angry this has happened
    I hope you will show your support and help me solve this.
    If this is not the right site to report this or find out if this is a scam, please guide me to the correct area.
    Thank you for your attention.
    Sue Keeffe Ayton
    Sydney Australia
    <Personal Information Edited by Host>

    Apple does not give away its products.
    Unless you are the 1,000th person to show up at a new Store and Tim Cook is there and his assistant is filming you to be posted on their Home Page.
    That is yet another FaceBook SCAM.

  • In the name of hearing loss and equal access, there needs to be a balance control for people who have decreased hearing in one ear only. It is STILL not available in itunes YET, despite MUCH clamor. WE NEED BALANCE/Pan/L-R control!

    OK, there's been complaining about this for YEARS, and now I have a relative who has extreme hearing loss in one ear (not deaf) and usually compensates by turning up the balance on her speakers/ipod to the left or right side in order to compensate.
    Also, as a musician and a guitar teacher, I make teaching audio tracks that have a particular part on the left or the right side only, and which needs to be "muted" by panning to the opposite side, then the student can play to the backing track without that part. Of course, then they can adjust the balance back and check themselves. This is also done with a LOT of jazz teaching exercises, etc...
    Apple-PLEASE give us an elegant, easy to get to way of adjusting balance WITHIN ITUNES. Most of us us professional grade equipment and sound interfaces, and care deeply about the quality of sounds we make. we do NOT want to have to keep going into Prefs in order to adjust balance, and a LOT of high end sound interfaces don't allow that anyways anymore.
    PLEASE PLEASE PLEASE fix this Apple. It should be easy, it should be done in the name of compassion for those with one sided hearing loss  if for no other reason, but I've outlined other reasons to do it as well.
    AND I'll repeat this for the people who won't read what I wrote---WE DO NOT NEED TO BE TOLD TO "ADJUST IT UNDER PREFERENCES"---that defeats the point of having a simple solution, and it certainly won't work on an ipod.
    HELP! You guys can fix this IMMEDIATELY if you will just DO IT! I cannot stress how important it is to the music community as a whole...
    Why has this not been done before now? Even the cheapest, sorryest stereo receivers, players, etc., in the world have ALWAYS had a "balance" control along with a "bass" and "treble" even at their simplist. Its PAST time for iTunes to become something better. WAY PAST.
    AND AGAIN---DOING IT THROUGH PREFERENCES IS NOT POSSIBLE FOR THOSE OF US USING "REAL" INTERFACES or playing on a iPod, etc...

    -> Feedback and Suggestions.

  • I am sending text messages to some people who think they come from my husband.  Also evertime I send a text to my husband, a copy is sent to me too.

    I am sending text messages to some people who think they come from my husband.  They have both my name & number and my husbands name and number in their contacts.  Also everytime I send a text to my husband, a copy is sent to me too.  I do however receive text message from people to my phone and it seems to work fine if they do not have my husbands info.

    You don't necessarily need separate AppleIDs, but you need to set the Send and Receive for Messages to different addresses (Settings App > Messages).

  • With iOs 7 and the iPhone can someone use the phone while also using a communication app such as Speak It or Assistive Chat? These are text to speech systems for people who cannot speak well. Thanks you!

    With ios 7 and the iPhone can someone use their phone while also using a text to speech app, such as Speak It or Assistive Chat? These apps are used by people who have difficulty with speech production.
    Thank you.

    My iPhone 5 wouldn't start after I turned it off a few minutes after writing this. It went into recovery mode and I had no choice but to connect to iTunes on PC and restore.
    I restored to factory setting first, just to validate my phone was okay. For a second consecutive iOS update, the  iPhone 5 did not update smoothly while connected to PC and iTunes - I had to retry two times before the progress bar for the update showed. (The exact same problem with the restart occured when I updated to 7.0.4.)
    The good news is that I was ultimately able to restore the iPhone 5 to factory settings while running iOS 7.0.6. I did have a backup from about a month ago lying around and was able to successfully restore with that as well, so the damage done is almost negligible since I had my contacts, notes, mail, etc. backed up to iCloud.
    Once I completed both restores, the sync with iTunes worked fine.

  • To people who has Filevault Problem

    I might had brain shortage last night. I turned on Filevault w/o doing any research. After restart my computer. I had problem login to my account. It took me all night until now. Finally, I solved it. I had been search with any related post, but none of them work.
    After computer restart, I entered my password. It took 15 - 20 secs and return with message " you are unable to login "XXXX" account because filevault has an error."
    I changed my Master Password, reset my account password. Verify Disk permission. nothing really help.
    The way I solved this problme is
    1.Login to another account with Administrator permission.
    2.Go to System Preference
    3.Go to Account
    4.Delete the account you enable the filevault
    5.After you click "-" sign, it will ask you with 3 opinions.
    5-1. Save the account home folder in Disk Image.
    5-2. Do not change the home folder
    5-3. Delete the home folder.
    PLEASE SELECT Opinion 2 "DO NOT CHANGE THE HOME FOLDER"
    After delete the account. Create a SAME ACCOUNT NAME with the SAME PASSWORD (Master Password)
    Log out and Login with the account you just created. System will asked if you want to use the same home folder. Just click "YES"
    After login,You will back to the original setting on the account.
    Hope this will help people who stuck on filevault problem
    DO NOT ENABLE FILEVAULT UNLESS YOU ARE READY FOR PROBLEM.

    Hey Fresh Blue,
    I wanted to change my "short name" (the name that shows up on the home folder).
    Do you think I can do what you did to change the short name and keep the contents of my home folder.
    Delete my current account, and not delete the home folder, create a new account with a different short name.. then log on with the new account and use the same home folder?

  • I am trying to watch Prof. Susskind's video lectures from Stanford univ.U-tube lec work fine.With itunes video and audio have synch problem.Is there a way to fix this or the people who uploaded messed up and it is too late?

    I am trying to watch Prof. Susskind's lectures from Stanford Univ. U-tube lectures work fine.With I-tunes, there is a synchronization problem between audio and video. Is there a way to fix this or the people who uploaded messed up and it is too late?

    I had thought this situation was solved but it just got worse. In addition to being without service for several days I am now being charged  a cancellation fee for a broadband service that BT disconnected in error. BT Vision was also terminated by BT but the set up charges are still in place. Does anyone know who the relevant Ombudsman is? I called BT from America on Friday - for an hour - while someone called Aruj sorted out why there is an order 'in progress' that I didn't initiate; why I have fees relating to a problem created by BT and why there are references to a house move that didn't take place and a BT Vision service I no longer have but didn't cancel myself. He assured me it would be rectified and my bill would be reduced by 139 pounds and we would get confirmation of this later that day. I asked him what chance there was that this would not actually happen - he said no chance at all; my new bill would be 23.50.
    There was no text message. An online chat person today told me there had been a fee reduction request which had been declined and there was nothing else he could help me with as he dealt only with broadband. But he would get BT Vision to email me. They always seem so helpful.............
    I'm sure I'm listed somewhere as 'a problem', there's no other explanation for why I get the runaround

Maybe you are looking for

  • Error message withg sync, tried everything, nothing helped. Please help me.

    Gets error message "Attempting to copy to the disk "Ipod" failed. The disk could not be read from or written to". It will put on about 15-30 songs before displaying this message, and can fully sync but it takes forever because i have to press "ok" th

  • Upgrade to OS 10.9.4 and having multiple issues

    I upgraded to OS 10.9.4 and now Mail will not open, says it needs to rebuild index but it won't. I get ICloud password prompt and when I try to connect it says there are problems opening Icloud pane. After reading other questions I went in to Console

  • PCI-6221 fails self-test in MAX but device manager says it's working

    Hi everyone, I bought a few PCI-6221 (37-pin) data acquisition cards and have been able to get one to work but 3 others don't work. Device Manager sees them and says they work.  MAX sees them and when I run Self Test, they fail with error number -500

  • SSLv2Hello support with SunPKCS11/NSS in FIPS mode

    Does anyone know if there is a way to enable support for SSLv2Hello when the JRE is configured to use a FIPS crypto module? I have an NSS database running in FIPS mode, plugged into my JRE via the following lines in my java.security file: security.pr

  • Ssis to load dimension table

    i want to be able to generate a dimension out of fact table the attribute is the name of a store which can be spelt anyway. but in the dimension table, i want all the member values with similar spelling to correspond to a single store and mapped to a