new_here Posted November 22, 2015 Report Posted November 22, 2015 Assume that table DEPARTMENTS is using DEPARTMENT_ID as the primary key. A sample of records in the table can be found as follows Department ID Dept Name ManagerID location ID 10 Administration 200 1700 20 Marketing 201 1800 50 Shipping 124 1500 60 IT 103 1400 80 Sales 149 2500 90 Executive 100 1700 110 Accounting 205 1700 190 Contracting 1700 Write a SQL statement to find IDs of department pair which are in different location with known manager, and both department names end with “ing”. Can any one help this with Solution thanks
Silver_mani Posted November 22, 2015 Report Posted November 22, 2015 select a.department_id from departments a join departments c on a.department_id = c. department_id where a. location_id <> c.location_id and and a.manager_id is not null and a. department name like '% ing'
KharjuraNaidu Posted November 22, 2015 Report Posted November 22, 2015 select a.department_id from departments a join departments c on a.department_id = c. department_id where a. location_id <> c.location_id and and a.manager_id is not null and a. department name like '% ing' dept id primary key antunnadu... alantappudu oka dept multiple locations undadhu ga
ARYA Posted November 22, 2015 Report Posted November 22, 2015 Assume that table DEPARTMENTS is using DEPARTMENT_ID as the primary key. A sample of records in the table can be found as follows Department ID Dept Name ManagerID location ID 10 Administration 200 1700 20 Marketing 201 1800 50 Shipping 124 1500 60 IT 103 1400 80 Sales 149 2500 90 Executive 100 1700 110 Accounting 205 1700 190 Contracting 1700 Write a SQL statement to find IDs of department pair which are in different location with known manager, and both department names end with “ing”. Can any one help this with Solution thanks select department_id from departments x join deparments y on x.locationid<>y.loctaionid where dept_name like '%ing' and managerid is not 'null';
ARYA Posted November 22, 2015 Report Posted November 22, 2015 dept id primary key antunnadu... alantappudu oka dept multiple locations undadhu ga kani same location lo different dept unnai.. the query needs depts in different location
Silver_mani Posted November 22, 2015 Report Posted November 22, 2015 dept id primary key antunnadu... alantappudu oka dept multiple locations undadhu ga artham kale mama ...let me read again ... i might be wrong
KharjuraNaidu Posted November 22, 2015 Report Posted November 22, 2015 kani same location lo different dept unnai.. the query needs depts in different location correcte... kani data choodu... e dept multiple locations lo ledu... paiga dept PK oka locn lo multiple dept undochu kani vise versa kudaradu... unless Dept+Locn PK aithe
Silver_mani Posted November 22, 2015 Report Posted November 22, 2015 select department_id from departments x join deparments y on x.locationid<>y.loctaionid where dept_name like '%ing' and managerid is not 'null'; nasty unkul ... ila un indexed fields meeda join cheyaku ...pedda tables aithe biscuit padtadi
ARYA Posted November 22, 2015 Report Posted November 22, 2015 nasty unkul ... ila un indexed fields meeda join cheyaku ...pedda tables aithe biscuit padtadi req ade ga...kani nuvvu dept id meeda ela sesav man? pedda tappu nee query..asalu adigine list of dept ids nuvvemo dept ids meda join rasesav asalu em job sestunnav nee silver lo naa gold
ARYA Posted November 22, 2015 Report Posted November 22, 2015 correcte... kani data choodu... e dept multiple locations lo ledu... paiga dept PK oka locn lo multiple dept undochu kani vise versa kudaradu... unless Dept+Locn PK aithe naa query ite correct kada mayya inka ee req ki alane rayali
Silver_mani Posted November 22, 2015 Report Posted November 22, 2015 req ade ga...kani nuvvu dept id meeda ela sesav man? pedda tappu nee query..asalu adigine list of dept ids nuvvemo dept ids meda join rasesav asalu em job sestunnav nee silver lo naa gold nee banda bada self join ....they will match ... you will get the results naa
ARYA Posted November 22, 2015 Report Posted November 22, 2015 nee banda bada self join ....they will match ... you will get the results naa req lo same depts ani evadu adigaadu nee bonda nee tadullage unnai nee querys #silverism @3$% req sarriga saduvu different location, known manager , and dept names ending with 'ing' why the frock did you join for same dept ids?
Silver_mani Posted November 22, 2015 Report Posted November 22, 2015 req lo same depts ani evadu adigaadu nee bonda nee tadullage unnai nee querys #silverism @3$% req sarriga saduvu different location, known manager , and dept names ending with 'ing' why the frock did you join for same dept ids? husshhhhhhhh ...ade ga cheptunna unkul ... self join chesappudu primary key meeda join chesko eppudaina ..... mostly they will be indexed
ARYA Posted November 22, 2015 Report Posted November 22, 2015 husshhhhhhhh ...ade ga cheptunna unkul ... self join chesappudu primary key meeda join chesko eppudaina ..... mostly they will be indexed naku nerpistunnava sql edisinatte undi nee sql #selfjoinsilver @3$%
Recommended Posts