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

use aggregates (min, max, avg) in CONSTRUCT query [duplicate]
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

Categories

HOME
logging
indexing
teradata
network-programming
glsl
pip
revit-api
token
coding-style
normals
aspectj
opendaylight
popup
multibinding
indri
google-street-view
formulas
polybase
smali
email-client
datastax-enterprise
expressionengine
smart-device
android-6.0-marshmallow
custom-fields
git-submodules
pushpad
multilanguage
keil
slim-lang
imdb
apache-falcon
javax
var
icu
binary-decision-diagram
cakephp-3.2
runner
openidm
runtime-permissions
dna-sequence
sharpdevelop
sharpssh
androiddesignsupport
bipartite
rmq
wicketstuff
blitz3d
fileopendialog
portaudio
scikit-image
rowname
syslog4j
csc
sprockets
objectify
nimbus
php-java-bridge
supervised-learning
audiorecord
angular-i18n
archiva
paypal-subscriptions
innertext
chomsky-normal-form
code-translation
kramdown
imageicon
angular-promise
jcomponent
mojolicious
database-project
php-gd
adempiere
grails-3.0.9
ultraedit
crtdbg.h
selenium-grid2
telerik-appbuilder
class-library
infor-eam
imaplib
code-complete
mencoder
mobile-robots
angularjs-select2
typography
mosix
uikit-dynamics
cloudmade
django-tinymce
ncml
xcode4.6.3
datasheet
unordered-set
datejs
visual-leak-detector
gmagick
javah
http-response-codes
djangoappengine

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