sql - Using Select Distinct in Nested subquery -
i have select distinct query identifies location id(pk). want identify location name end user. thought subquery return it. returns value of 1. instead of actual location id when run select distinct query separately (25). can't seem figure out why.
select location.locationid, location.location location (location.locationid)=( select count(*) uniquelocations ( select distinct transactionlocation transactions (transactions.transactionactivity) = [enter activity] , (transactions.transactiondate) between [enter start date:] , [enter end date:] ) ); transaction table
transactionid(pk)| transactionemployee|transactionactivity|transactionlocation|date 1 | 1001 | 1 | 25 | 01/01/2014 2 | 1002 | 1 | 25 | 01/02/2014 3 | 1003 | 1 | 25 | 01/03/2014 location table
locationid(pk)|location name 24 | chicago 25 | pittsburgh 26 | boston thanks mike
i think maybe might want this:
select location.locationid, location.location location location.locationid in (select distinct transactionlocation transactions transactions.transactionactivity = [enter activity] , transactions.transactiondate between [enter start date:] , [enter end date:]);
Comments
Post a Comment