aggregate-functions


where clause and aggregate functions


Deposit(accno,cname,bname,amount)
Question:List the name of customer having max deposit in branch B1.
Answer: Select cname
from Deposit
where amount in (select max(amount)
from deposit
where bname='B1');
IS THE ANSWER CORRECT?IF NO,PLEASE POINT ME OUT THE MISTAKE AND EXPLAIN THE CORRECT ANSWER FOR THIS.
Thank You.
It is correct but it will probably be slow on a large dataset and if you don't have indexes on amount and bname.
I would rather use something like
SELECT cname FROM Deposit WHERE bname='B1' ORDER BY amount DESC LIMIT 1;

Related Links

R: transposing and aggregating columns
SQL Query Aggregate Error
Usage of aggregate functions in MarkLogic
Querying customDimensions in Google Bigquery
NHibernate - QueryOver criteria appearing in Where instead in Having clause, error
Howto aggregate on full data set in Spring Batch jobs?
Creating an aggregate function fails
Necessity of declaration of function in c and cpp
Calculate window average in tableau
Complexity asymptotic relation (theta, Big O, little o, Big Omega, little omega) between functions
What are TOP_COUNT and TOP_MAXCOUNT in BigQuery?
marklogic need advise for approach to aggregate documents
multiply(num) aggregate function in postgresql
Binding the Result of an Aggregate Function to a Projected Variable
tableau aggregate data based on dimension
where clause and aggregate functions

Categories

HOME
cxf
ldap
latex
liquibase
django-middleware
overrides
install
google-my-business-api
mongoimport
kairosdb
elastalert
chef-recipe
javascript-debugger
multibinding
taxonomy
passbook
jq
cherrypy
smali
concatenation
units-of-measurement
folder
multilanguage
visual-studio-debugging
restler
tunnel
ragel
lighting
azure-storage-files
electron-packager
pyexcel
definition
vpython
libzip
risc
gridgain
hierarchical-clustering
nao-robot
jscoverage
dynamic-linking
google-scholar
copy-constructor
zsh-completion
easy68k
razorengine
bbedit
sqldataadapter
askbot
dynamics-nav
app-data
webservices-client
play-json
dpkt
playn
avd
cl.exe
uiblureffect
fedena
clearcanvas
breeze-sharp
pytz
nest-initiative
lettuce
jsmpp
iwork
connections
mixradio
kuka-krl
vbaccelerator
complete
surfaceview
nsnumber
leap-year
ntdll
gpl
libx264
idoc
gssapi
certificate-revocation
filedialog
winrt-async
bash4
socketasynceventargs
mscorlib
jqtransform
excellibrary
http-response-codes
miniport
data-formats
manuals
jgrowl
urlscan

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App