I have a code I've made but I'd like to hide the column. So that it only shows the storeID instead of the SALARY along with it. I know I need to wrap it around in another set of brackets, but don't know where to do that. Also can anyone tell me a technique to identify where to use the brackets? Sorry, not too familiar with MySQL, but have been learning for couple of weeks now. Just finished the diagrams with Chen Notations, now the codes.
SELECT storeID, SUM(SALARY) FROM STORE
WHERE SALARY < expenditure;
Currently it's displaying:
| storeID | | SUM(SALARY) |
| 1 | | £30000 |
| 2 | | £25000 |
| 3 | | NOTHING |
I want the second column SUM(SALARY) to be hidden. Thanks in advance.
EDIT: I wasn't being too clear. I needed to calculate the SALARY (sum of all salaries from each store), and find the storeID's with SALARY < expenditure.
EMPLOYEE = SALARY
STORE = storeID and expenditure.
SELECT StoreId FROM ( SELECT storeID, SUM(SALARY) FROM STORE JOIN EMPLOYEE WHERE SALARY < expenditure )
this should work ;)
SELECT storeID FROM STORE JOIN EMPLOYEE WHERE SALARY < expenditure;
Yes you will need an Alias for this
SELECT x.name, x.branch FROM ( SELECT person.name AS name, person.email, branch.name AS branch FROM person JOIN branch ON person.branch_id = branch.id )x
So I name my query block with x, even you can reference by x like