Fixing this Scalar Variable Syntax question

Please help me to correct this syntax for this practice question below.
/* Create and set a Variable equal the number of Flights that were late.*/
DECLARE @FlightsLate varchar(50)
SET @FlightsLate = (SELECT* FROM
Flights WHERE Ontime = 0)
SELECT @FlightsLate

If you want to get the total numbers that are late you need to do this
DECLARE
@FlightsLate varchar(50)
SET
@FlightsLate = (SELECT count(*) FROM
Flights WHERE
Ontime = 0)
SELECT
@FlightsLate
Assuming that Ontime =0 means Late
Javier Villegas |
@javier_vill | http://sql-javier-villegas.blogspot.com/
Please click "Propose As Answer" if a post solves your problem or "Vote As Helpful" if a post has been useful to you

Similar Messages

  • Scalar Variable Syntax questions

    I am practicing Scalar  Variables in a workbook.  Can some help me answer these questions working with Variables.   The Table name is Flights.
    Create and set a Variable equal to the number of Flights that were late.
    Multiply that amount by the amount lost per late flight ($1,029) and store the amount in another variable.
    Take the total amount lost (#4) and subtract it from Total profit ($45,000) and store that number in a variable.
    Find out the Earliest FlightDate and add 10 years to it and store it in a variable.
    Find out the day of the week for the Latest FlightDate and store it in a variable.

    I'm not really sure how you would benefit from we giving the answers to your exercises. How would you learn from that?
    I will only point what I think is a misunderstanding. When they say Create and set a Variable equal to the number of Flights that were late., I think they mean a scalar variable, not a table variable.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • Fixing this Table Variable Query

    Please assist me to correct this syntax for this Table Variable Question below.   
    /* Create a table variable with Departure City and State in 2 different columns along 
    with Flight Destination City and Ontime. */
    DECLARE @NTable TABLE (FlightDepartureCity varchar(50), FlightDepartureCity1 varchar(50),FlightDestinationCity varchar(50), [Ontime] INT)
    INSERT INTO @NTable 
    SELECT Left(FlightDepartureCity,CHARINDEX('-',FlightDepartureCity)-1) as City,
    RIGHT(FlightDepartureCity,LEN(FlightDepartureCity) - CHARINDEX('-',FlightDepartureCity)) as FirstName,
    FlightDestinationCity, Ontime
    FROM Flights
    SELECT Left(FlightDepartureCity,CHARINDEX('-',FlightDepartureCity)-1),
        RIGHT(FlightDepartureCity,LEN(FlightDepartureCity) - CHARINDEX('-',FlightDepartureCity))  , 
        FlightDestinationCity, Ontime FROM @NTable

    Disregard I figured it out
    DECLARE @NTable TABLE (FlightDepartureCity varchar(50), FlightDepartureCity1 varchar(50),FlightDestinationCity varchar(50), [Ontime] INT)
    INSERT INTO @NTable 
    SELECT Left(FlightDepartureCity,CHARINDEX('-',FlightDepartureCity)-1) as City,
    RIGHT(FlightDepartureCity,LEN(FlightDepartureCity) - CHARINDEX('-',FlightDepartureCity)) as FirstName,
    FlightDestinationCity, Ontime
    FROM Flights
    SELECT * from @NTable

  • I am trying to reset my security questions and i am not getting an email from apple... can anyone please tell me what i need to do to fix this?

    i am trying to reset my security questions and i am not getting an email from apple... can anyone please tell me what i need to do to fix this?

    Forgotten Security Questions/Answers
    You need to contact Apple by:
    1 - Use the Express lane and start here:
    https://expresslane.apple.com
    then click More Products and Services>Apple ID>Other Apple ID Topics>Forgotten Apple ID security questions.
    or
    Apple - Support -form iTunes Store - Contact Us
    2 - Call Apple in your country by getting the number from here:
    http://support.apple.com/kb/HE57
    or           
    Apple ID: Contacting Apple for help with Apple ID account security
    3 - Use your rescue email address if you set one up
    Rescue email address and how to reset Apple ID security questions
    For general  information see:
    Apple ID: All about Apple ID security questions

  • TS2446 my account was disabled because i could not remember my security question awnsers... how do i fix this and reset my awnsers

    how do i fix this?

    Reset Security Questions
    Frequently asked questions about Apple ID
    Manage My Apple ID
    Or you can email iTunes Support at iTunes Store Support.
    If all else fails:
    Go to: Apple Express Lane;
    Under Product Categories choose iTunes;
    Then choose iTunes Store;
    Then choose Account Management;
    Now choose iTunes Store Security and answer the bullet questions, then click Continue;
    Sign in with your Apple ID and press Continue;
    Under Contact Options fill out the information and advise iTunes that you would like your security/challenge questions reset;
    Click Send/Continue.
    You should get a response within 24 hours by email.
    Another user had success doing the following:
    I got some help from an apple assistant on the phone. It is kind of round about way to get in.
    Here is what he said to do and it is working for me...
    on the device that is asking you for the security questions go to "settings", > "store" > tap the Apple ID and choose view"Apple ID" and sign in.
    Tap on payment information and add a credit/debit card of your preference then select "done", in the upper right corner
    sign out and back into iTunes on the device by going to "settings"> "store" > tap the Apple ID and choose "sign-out" > Tap "sign -in" > "use existing Apple ID" and you should be asked to verify your security code for the credit /debit card and NOT the security questions.
    At this time you can remove the card by going back in to edit the payment info and selecting "none" as the card type then saving the changes by selecting "done". You should now be able to use your iTunes store credit without answering the security questions.
    It's working for me ...I just have to put in my 3 digit security pin from the credit card I am using.
    Good Luck friends!

  • I keep getting the message that my adobe flash player plugin has crashed   what can I do to fix this

    I keep getting the message that the adobe flash player plugin has crashed   what can I do to fix this problem

    Maybe post your question in the Flash Player forum?
    http://forums.adobe.com/community/flashplayer

  • Hi! I want to restore my last 2 months email and I can't find the email. I just realize that I accidentally deleted that email today  -_- Anyone knows how I can fix this problem?

    Hi! I want to restore my last 2 months email and I can't find the email. I just realize that I accidentally deleted that email today  -_- Anyone knows how I can fix this problem?

    Security questions:
    https://discussions.apple.com/docs/DOC-4551
    http://support.apple.com/kb/HT5312
    This is also useful:
    http://www.macworld.co.uk/ipad-iphone/news/?newsid=3463233&olo=email

  • I have recently bought macbookpro but it is getting slow down. How to fix this issue

    I have recently bought macbookpro but it is getting slow down. How to fix this issue

    Too vague a question.
    What is slow... the bootup... or something else?
    Start with repairing disk permissions.

  • I forgot my security question answers for my ipod, what can i do to fix this so i can buy stuff again?

    Hi, ive had my ipod for about a year. I used it frequently until my charger broke then it pretty much collected dust for the next 3 or 4 months. but ive started using it frequently again because i finally found a charger for it that works ( long story short, i was stupid and didnt think that it was my laptops usb ports that werent working . I ended up buying a port and im wall charging it now) but now, when i want to buy a song or an app thats money it wont let me! I have 7 dollars in this account but it says i have to answer my security questions since its been so long. I forgot them!! Is there anyway I can possibly fix this to where i can use my account and its money again or should i cut my loses and make another account?
    Any help I'm thankful for!!c:

    Click here for information. If the option to have the answers emailed to you isn't available or doesn't work(the email may take a few hours to arrive), contact the iTunes Store staff via the link in the 'Additional Information' section of that article.
    (90678)

  • Apple is asking me to answer my security questions but I can't remember the answers. Also I would reset them but my rescue email is no longer in use and I cannot even remember what it was. Is there any way to fix this mess?

    So basically I need to confirm my identity but I  can't because I can't remember the answers to my security questions. I scheduled a meeting with Apple, to see if they can fix it. Nod I would just reset them from my rescue email, but I don't know what that email is and it's also no longer in use.
    Do you know of any way to fix this?

    You won't be able to change your rescue email address until you can answer your questions, you will need to contact iTunes Support / Apple in your country to get the questions reset.
    Contacting Apple about account security : http://support.apple.com/kb/HT5699
    When they've been reset you can then use the steps half-way down this page to update your rescue email address for potential future use : http://support.apple.com/kb/HT5312

  • TS1424 I have an ipad and an iphone on two seperate itunes account and i can not make an itunes purchase on either device.  I keep getting asked for answers to the securtity question which i never answered in the first place! How do i fix this?

    I have two seperate itunes accounts on two seperate devices and i can not make an itunes purchase on either one. When signing into the account it ask for the  answer to security questions. I have NEVER answered a security question for these accounts.  Each time it is a different set of questions. This has only happend since the original devices have been replaced/upgraded. How do I fix this?   There is money in each account and both have recieved itunes giftcards for christmas that they are unable to use!

    sailsalot wrote:
    I have a new ipad and have used the community to answer questions for myself.  Your help has been great!  I don't know how you got my sailsalot name from my Skype account but I signed in with you as "gags76" and got help with my new ipad.  I discovered I used a different Apple id and password on my ipad from my computer (imac) and changed that.  My e-mail is   Could you email me if there is something I should do at my end.  I have to use itunes to sync with my ipad so I have been going back and forth between the two.  Should I sign in with my proper Apple id on my ipad?
    Yes

  • I am trying to open up my iTunes onto our new computer but do not remember the answers to the securty questions. The e-mail verification is being sent to an outdated e-mail address. How can I fix this?

    I am trying to open up my iTunes onto our new computer but do not remember my answers to the security questions. The e-mail verification is being sent to an outdate e-mail address I no longer have access to. I updated the e-mail address in my iTunes account but it will not send it to the updated e-mail. Is there any way I can fix this?

    Click here and request assistance.
    (80090)

  • My wife's iTunes ID will no longer work.  Tried to reset password but did not get email, tried to reset by answering personal questions' but will not accept the correct date of birth.  Has it been hacked?  How can I fix this?

    My wife's iTunes used ID will not work.  Tried resetting the password, but email was not received.  Tried using personal questions method, but would not accept the correct date of birth, so could not go any further.  Has her iTunes ID been hacked?  How can I fix this?

    Thanks for that advice @randers4.
    I linked through and submitted my info as a "topic not covered" in the iCloud section. After entering the serial number of my MBP it turns out I wasn't eligible for technical support (though I don't think this is hardware related support) and the final suggestion was to take my computer into an Apple store. I called my local Apple reseller and asked for assistance. The customer service rep was very nice but unable to help, so suggested I call Apple Support on 1300 321 456. I did so and, again, spoke to two very polite and helpful customer service people (I was transferred to security services). I didn't have to be on hold to speak to either rep for more than a few seconds! After trying a few different things, he worked out what was happening...
    So, to cut a long story short, to solve the problem in my OP, all I had to do was log out of iCloud in my System Preferences and log back in using my current Apple ID. [Edited to add that I had to sign out of everything I was currently signed in to with my Apple ID before logging out and in again.]
    Problem solved!
    Message was edited by: NotBaconBits

  • On Ibooks Author, my programmed image for the Chapter page no longer shows up on new pages, just appears as a question mark inside a box, How do I fix this?

    On Ibooks Author, my programmed image for the Chapter page no longer shows up on new pages, just appears as a question mark inside a box, How do I fix this? Please help, its the same when I try and copy and paste the same image within Ibooks author.

    https://discussions.apple.com/message/24420017#24420017
    You may have  moved or removed content on your page or  its possible you  used the"Adjust Image" and over sharpeed one or more images.
    I assume  you mean it does not show up of new Chapter pages... have you checked the  template?
    Where you see the  ?    you  need to either reduce teh  box outline size - or drop anther  copy of the original image onto  it, it may  fill the  ? box or sit on top.... delete the ? box.
    If its Chapter page only related, its  better doing this in the template.
    Is you image .jpg or .png?

  • "File could not be found" message on top of all images in Library:  How do I fix this?[was:Question]

    New to LR 5.2 Running OS X 10.8.5. Tried to save image in file folder. Now get this message at top of all images in Library: "File could not be found." How do I fix this?

    “Save” is not a term used with LR to create images.  What are you trying to do, exactly, in terms of LR menu options? 
    Are there questions marks on the thumbnails for the images that say File could not be found?
    Sometimes a screenshot can communicate things quicker than words.

Maybe you are looking for

  • When posting GI for Non valuated material in Delivery geting error (M8147)

    Hi Experts We have a problem that we are trying to send a material from one plant in one company code to another plant in another company code (Inter Company Stock Transfer Order). The material is of type Non Valuated (So it has no valuation class).

  • Nik Filters Crashing Photoshop CS4??

    I have been using Nik filters since they first came out. When Google took over I townload the whole free suite they offered. Than I was 'force fed' Nik Analog and it slowed all of my Nik filters down, and since then I have had periods of tremendeous

  • Drop Shadow on FacesMessage

    Hi I have a facesmessage that i add to the facescontext when a user does not select a option. The message has a large drop shadow that i would like to remove. Any Ideas Also if i could use a different kind of pop up without a drop shadow that would w

  • Inspection Lot for inspection type 09_ Vendor field is blank

    Hi, Inspection lot for inspection type 09. I am not getting the vendor name in inspection lot details. Vendor field is blank. I need this field updated. Please guide me what to do for this. Thnaks & Regards Kundan kumar

  • Multiple Page Forms

    I have a form, that I'd like to combine into multiple pages after it's been filled out. However, when I do this, all the form field information is replace with that of the first page. Is there a way to combine multiple forms into a single document, w