Sql query the store that has best sell quality in pubs sample database

In pubs database, I want to query the store in which has highest sales quality. I exec following query,
select stores.stor_id, sum(sales.qty) as sumqty
from stores
join sales on stores.stor_id = sales.stor_id
group by stores.stor_id, stores.stor_name
Results:
6380 Eric the Read Books 8
7066 Barnum's 125
7067 News & Brews 90
7131 Doc-U-Mat: Quality Laundry and Books 130
7896 Fricative Bookshop 60
8042 Bookbeat 80
The result I need is 
7131 Doc-U-Mat: Quality Laundry and Books 130
Could anyone give me some suggestions?
Thanks.

Hello,
If you don't want to use TOP , you can try to used nested query to get MAX(SUM()) value. Please refer to the following statement:
SELECT stores.stor_id, sum(sales.qty) as sumqty
FROM stores
JOIN sales ON stores.stor_id = sales.stor_id
GROUP BY stores.stor_id, stores.stor_name
HAVING sum(sales.qty)=
( SELECT max(sumqty) FROM (
SELECT stores.stor_id, sum(sales.qty) as sumqty
FROM stores
JOIN sales ON stores.stor_id = sales.stor_id
GROUP BY stores.stor_id, stores.stor_name) AS s)
Regards,
Fanny Liu
Fanny Liu
TechNet Community Support

Similar Messages

  • SQL Developer asks for java.exe with the version that has java built in.

    I have a user with the following platform:
    Windows XP2
    SQL Developer Version 1.5.4
    The version they are trying to get running is the one that has the JDK built in. However, when they try and startup SQL Developer it asks for the location of java.exe.
    However, when I run the same exact version on my workstation, I do not receive the prompt for a java.exe.
    I checked the documentation, and I couldn't find anything related to this particular issue, however I may have missed it.
    Can anyone provide me with any guidance please? Thanks.

    Resolved. There was a difference of permissions on the user's machine.

  • Does anyone know of an e-reader app for the iphone that has text to speech capability? I have a Kindle 3G that can read whole pdf documents and books but I cannot figure out how to do it on my iphone 4.

    Does anyone know of an e-reader app for the iphone that has text to speech capability? I have a Kindle 3G that can read whole pdf documents and books but I cannot figure out how to do it on my iphone 4.
    All of the apps I have found on the App store either do not have the text to speech capability or if they have it they will only read a page at a time or simply read the text you paste into their window. I really do not understand what is so difficult about having this feature as Kindle provides it--though Amazon does not make the feature available on its iPhone 4 app.
    Please help.

    thanks. yes i am aware of the VoiceOver feature but it is NOT the solution to my problem. as you said, it is a solution to a different set of issues. i want the text to speech ability because i there are books i need to read but do not have the time to sit down and read them and have become used to listening to them read to me either by a professional human reader or with the text to speech software on the Kindle.
    I think Apple makes the best audio devices but i am really disappointed in this inexplainable shortcoming. if apple can give us siri they ought to be able to design a nice little button that i can push to turn on text to speech while i am in a document, book, magazine or webpage. clearly it is possible as apple has added the "reader" button in safari to have web pages dropped into the reader format.
    thanks for your suggestion though, it is what everyone suggests but it does not address the issue.

  • Apps in the store that have zero reviews, yet 4.5 million downloads

    "I see many apps in the store that have zero reviews, yet they are top of the list as displayed by Apple.
    One caught my eye as there own website claims 4.5 million unique downloads. Yet the same app has no reviews in the App store?
    What gives? I may not be one to dolots of  reviews but after 4.5 million surely a few people would have bothered to send in a review?
    No link to software as I do not want to be accused of promoting it.
    So whats the point of a review system if you don't publish them?

    That's just great, defend the app by insinuating that the purchasers are stupid.  To answer your question of what else one might need --
    1)  The portion of the title that is first presented to the user should make it clear that the app is not Microsoft Word 2010.
    2)  The icon should not contain the W in the blue box.
    Here, for example, we have a legitimate book on Microsoft Word, namely "Word 2010 for Dummies."  Notice that the images on the cover are totally different from Microsoft's icon. 
    http://www.amazon.com/Word-2010-For-Dummies-Gookin/dp/0470487720/ref=sr_1_3?s=bo oks&ie=UTF8&qid=1336054960&sr=1-3

  • I wish to use the previous version not the one that has today been automatically installed. My settings were to let me know and I decide to install when I'm ready

    I wish to use the previous version not the one that has today been automatically installed. My settings were to let me know and I decide to install when I'm ready, how do I go back. This because one of the previous Plugins does not work with this version, and they have no fix for it yet!

    FOR ASSISTANCE WITH ORDERS - iTUNES STORE CUSTOMER SERVICE
    For assistance with billing questions or other order inquiries, please refer to our online support page by clicking here: http://www.apple.com/support/itunes/store/. If you cannot find the answers you are seeking in our robust knowledge base, you can contact us by visiting the following URL http://www.apple.com/support/itunes/store/, clicking on the appropriate Customer Service topic, then using the contact button or email form at the bottom of the page. Responses to emails will be provided as soon as possible.
    Phone: 800-275-2273 How to reach a live person: Press 0 four times
    Hours of Operation: Mon-Fri: 9am-5pm ET
    Email: [email protected]
    How to report an issue with Your iTunes Store purchase
    http://support.apple.com/kb/HT1933
    How to Get a Refund from the App Store
    http://gizmodo.com/5886683/how-to-get-a-refund-from-the-app-store
    Canceling a Digital Subscription
    http://gadgetwise.blogs.nytimes.com/2011/10/14/qa-canceling-a-digital-subscripti on/
     Cheers, Tom

  • Can I use Apple Pay at any store that has an NFC reader or has that merchant had to have signed up to accept Apple Pay?

    Can I use Apple Pay at any store that has an NFC reader (with no Apple Pay logo) or has that merchant had to have signed up to accept Apple Pay?

    If the merchant accepts contactless payments, you should be able to use any contactless payment option (which includes Apple Pay).
    Some merchants (like CVS) have NFC readers but they have been deactivated because they are a member of a competing payment system (Current C).

  • The store app has disappeard from my ipod touch menu.  How do I get it back?

    The store app has disappeared form my ipod touch menu.  How do I get it back>

    Check in All Folders and on All Pages/Screens...
    Check in Restrictions...
    Settings > General > Restrictions
    If no joy...
    Settings > General > Reset > Reset Home Screen

  • I'm moving an internal hard drive from an old computer to a new computer.  How do I transfer the catalog data to my new computer so the Organizer of Photoshop Elements 6 will find the data on the hard that has been moved to the new computer?

    I'm moving an internal hard drive from an old computer to a new computer.  (My new compute runs Windows 8.1) How do I transfer the catalog data to my new computer so the Organizer of Photoshop Elements 6 will find the data on the hard that has been moved to the new computer?  Is this possible or do I have to use the procedure of copying the catalog along with the photos to a back up hard drive and then restore them on the new computer?

    The 'normal' procedure is to do a PSE organizer backup (not a copy or a backup from external tools) to an external drive, then a restore to the new location.
    The advantage is that you have a backup of both catalog and media files and you don't have all disconnected files, which would happen with external backup tools. Also, if you restore with a more recent elements version, the catalog will be automatically updated to the new format.
    The drawback in your situation is that you'll have either to overwrite all your files or restore to a custom location, creating a duplicate photo library (which supposes you have enough free space).
    It would be possible to simply use the organizer in the old PC to move the catalog to a new 'custom' folder just under your C: root drive. The catalog would be accessible once the drive will be installed in the new PC. Then you would have all files 'disconnected' due to the fact that all your media files are now on a drive with a different letter. Reconnecting a whole library is a hard job with PSE6, less so with PSE11/PSE12.
    If the idea of fiddling with the sqlite database with external sqlite manager tools is ok for you, I can describe the process more in detail. You only copy your catalog folder (as suggested above) to another location. Instead of trying the 'reconnection' way, you install the sqlite utility on the new computer. When the old drive is installed in the new computer, you simply edit a given record in the catalog database, catalog.psedb, and start the organizer with your copied catalog by simply double clicking the 'catalog.psedb' file.
    Even if the last solution is much, much quicker, I would still create a new PSE backup : you have never too much safety .

  • I need to get photos off a water damaged iPhone 3GS. Can I take out the component that has the photos (is this the main board?) and put it into another of the same phone to retrieve the photos? Please help

    I need to get photos off a water damaged iPhone 3GS. It spent time underwater, saltwater. I let it dry for a week, turned it on, the apple symbol came on, then it died. I need to retrieve my photos off it. Can I take out the component that has the photos (is this the main board?) and put it into another of the same phone to retrieve the photos? Please help

    You're talking about the logic board. The two most likely things to get toasted, with water damage, are the battery(it shorts out), & the logic board. The worst water damage would be salt water. I'm afraid your logic board is toast.

  • SQL Query - The number of columns specified in "SQL Query" does not match t

    I am creating new UDM for tablespace alert, below is my query,however its failing with error
    SQL Query - The number of columns specified in "SQL Query" does not match the value specified in "SQL Query Output"
    I selected Metric type is number
    SQL Query Format : Two columns
    Query:
    SELECT d.tablespace_name,round(((a.bytes - NVL(f.bytes,0))*100/a.maxbytes),2)
    used_pct FROM sys.dba_tablespaces d,(select tablespace_name, sum(bytes) bytes, sum(greatest(maxbytes,bytes)) maxbytes from sys.dba_data_files group by tablespace_name) a,(select tablespace_name, sum(bytes) bytes from sys.dba_free_space group by tablespace_name) f
    WHERE d.tablespace_name = a.tablespace_name(+) AND d.tablespace_name = f.tablespace_name(+)
    AND NOT (d.extent_management = 'LOCAL' AND d.contents = 'TEMPORARY');
    Any clues why i am getting error.

    SQL> SELECT d.tablespace_name,round(((a.bytes - NVL(f.bytes,0))*100/a.maxbytes),2) used_pct
    2 FROM sys.dba_tablespaces d,(select tablespace_name, sum(bytes) bytes, sum(greatest(maxbytes,bytes)) maxbytes from sys.dba_data_files group by tablespace_name) a,(select tablespace_name, sum(bytes) bytes from sys.dba_free_space group by tablespace_name) f
    3 WHERE d.tablespace_name = a.tablespace_name(+) AND d.tablespace_name = f.tablespace_name(+)
    4 AND NOT (d.extent_management = 'LOCAL' AND d.contents = 'TEMPORARY');
    TABLESPACE_NAME USED_PCT
    MGMT_TABLESPACE .82
    SYSAUX 1.52
    UNDOTBS1 .32
    RMAN .02
    CORRUPT_TS 10.63
    USERS 0
    SYSTEM 2.26
    MGMT_ECM_DEPOT_TS .04
    MGMT_AD4J_TS 0

  • My iPhone 5 has a grey-ish blue splodge on the screen. What is it and how can I get rid of it? The place that has the spot is about the size is about 2cm,it still works where the spot is. I haven't sat on my phone or hit it to hard, not that I remember.

    The place that has the spot is about the size is about 2cm,it still works where the spot is. I haven't sat on my phone or hit it too hard, not that I remember.  I  noticed a while ago. Will it disappear? I can see the things that should be where the spot is eg it's on the keyboard and I can see the keys. Will this spread to the whole screen? How can u get rid of this?

    If you own an iPhone that is ineligible for warranty service but is eligible for Out-of-Warranty (OOW) Service, Apple will service your iPhone for the Out-of-Warranty Service fee listed below.
    iPhone model
    Out-of-Warranty Service
    iPhone 5s, iPhone 5c,
    iPhone 5
    $269
    iPhone 4s
    $199
    iPhone 4, iPhone 3GS,
    iPhone 3G, Original iPhone
    $149
    A $6.95 shipping fee will be added if service is arranged through Apple and requires shipping. All fees are in U.S. dollars and are subject to local tax.

  • How to setup default gateway in a DHCP client. The default gateway will be the Ip address of the server that has RRAS installed, hence routing cabalities.

    How to setup default gateway in a DHCP client. The default gateway will be the Ip address of the server that has RRAS installed, hence routing cabalities.

    Hi Bill,
    Thank you for replying back...Yes, I was actually asking how do you set the default gateway address on the DHCP server?,
    I believe I got the answer below:
    To configure the DHCP default gateway option Click Start, point to Administrative Tools and then click DHCP. In the console tree, expand the applicable DHCP server, expand IPv4, and then right-click Scope Options Click Configure Options, check 003
    Router, type the applicable Server name and IP address, and then click OK.
    Thank you

  • Can I use an AE as a Bridge allowing me to hardwire my iMac and offer a wifi to my MacBook? The Ethernet in my office is hard wired but does come in from a router on the other end of the building that has a wifi that cant reach my office...

    Can I use an AE as a Bridge allowing me to hardwire my iMac and offer a wifi to my MacBook? The Ethernet in my office is hard wired but does come in from a router on the other end of the building that has a wifi that cant reach my office...

    Thanks, I thought so but wanted to be sure before running out and buying one...  I also called Apple Joint Venture and they helped me set it up without the Airport by using my iMac as the wifi!  Thanks again!

  • *Urgent*How to insert data from MS SQL to the table that create at the adobe form?

    Hi,
    I'm using Adobe life cycle designer 8 to do my interactive form. I would like to ask how to insert data from MS SQL to the table that i have created in my adobe interactive form?
    I really need the information ASAP as i need to hand in my project by next week... i really appreciate any one who reply this post.
    Thanks

    Tou need to do a couple of things
    1. On the Essbase server, set up an odbc system connection to your MySQL database
    2. In the load rule , go to the file menu and select open SQL data source and in the data source put in your SQL statement . A couple of hints. Where it says Select, don't put in the word select and where it say from don't put in from. The system adds them for you. The easiest way ti enter a SQL statement is to do it all in the select area So if your SQL would normanlly say select * from mytable just enter the code as * from mytable in the select area
    The click ol/retrieve and enter in your connection info. Itshould bring data back into the load rule. Save the load rule and use it

  • I had a box on the top of the browser that has written, you got mail. The problem is it keeps repeating you got mail. I don't want to hear it.

    I had a box on the top of the browser that has written, you got mail. The problem is it keeps repeating you got mail. I don't want to hear it.
    This is an unsolicited ad for "winning" an I phone. I am very tired of winning all this junk. I certainly do not want ads talking to me now.

    This appears above the page, in the toolbar area? That's probably caused by an add-on. Try disabling ALL nonessential or unrecognized extensions on the Add-ons page. Either:
    * Ctrl+Shift+a
    * "3-bar" menu button (or Tools menu) > Add-ons
    In the left column, click Extensions. Then, if in doubt, disable (or remove).
    Often a link will appear above at least one disabled extension to restart Firefox. You can complete your work on the tab and click one of the links as the last step.
    Does that get rid of the ad?
    Two other things:
    (1) You may want to check the Windows Control Panel, Add/Remove Programs, for any undisclosed bundle items. Click the "Installed on" column heading to group by date so they are easier to spot. Remove whatever looks suspicious or unnecessary.
    (2) You may want to supplement your regular security software with some of the scanning/cleaning programs listed in our support article: [[Troubleshoot Firefox issues caused by malware]].

Maybe you are looking for

  • Bluetooth in MacBook Pro won't pair with anything

    Hello all.  I have two MacBook Pros, each about 6 months old.  They are both running the latest version of Lion.  Neither one will pair with any bluetooth device.  I always get an error message saying "this device does not have the necessary services

  • Has anyone been in a similar situation?

    Here's my situation: In the past four months, my Powerbook has been posessed by the devil. Not that it hadn't been before..::wipes brow::. New combo drive, new display, new keyboard keys, new logicboard, new..something else that I know I repaired, bu

  • Need help on Date Parameters for BIP Report

    Hello, I need to add a date parameter in my BIP report. I have used a date parameter on a BIP report that has a for-each grouping, but my BIP report RTF template that was converted from Actuate do not have a for-each grouping and I was getting an err

  • Error when executing query

    Hi,   I have a report created using the infoset as an infoprovider. There are multiple reports created with this infoprovider. Few of them are working fine and few of them are not. The error for such erroneous reports are as below. Recently we upgrad

  • Database Storing

    I have created and asp form and connected to a sql database on dw. What is the next step for getting the submit button to store the form info in the sql database? I am missing something.