I have table like
id | t1 | t2
---------------
1 | a | b
2 | c | a
3 | a | e
4 | f | g
5 | c | c
I want to compare two columns with each other to remove matching records and get unique values in each columns, like
t1 | t2
-----------
a | b
c | null
null | ...
You forgot the joining condition (the on clause). Your penultimate attempt was almost correct, you only needed to replace one of the Employee instances with dbudget.
select ename from Employee INNER JOIN dbudget on Employee.did = dbudget.did where budget >500000
Although qualifying columns names with table names is also a good idea, so perhaps like this: select Employee.ename from Employee INNER JOIN dbudget on Employee.did = dbudget.did where dbudget.budget >500000
A further improvement would be to use short aliases for tables (may improve readability): select e.ename from Employee AS e INNER JOIN dbudget AS b ON e.did = b.did where b.budget >500000
Again, you are saying there that you are joining Project with Project, whereas the joining condition seems to suggest you should join Project with Employee.
Therefore, replace the first or second Project with Employee (i.e. either before or after the INNER JOIN)
i mean if i want to print the first year and the one after it and the did(department id) of departments that for two consequitive years had a budget of over 700000(a year)
for me it's complicated to write that as a query
even though it should be a simple one, as all of the elements are in: dbudget(did,byear,budget)
i am trying to write a query that shows department id, the first year, and the year after that of all departments that for two consequitive years were 700,000
SELECT did, byear, byear + 1
FROM dbo.dbudget d
WHERE EXISTS(SELECT 1 FROM dbo.dbudget
WHERE did = d.did
AND byear = d.byear - 1
AND budget = 700000)
AND budget = 700000;
My company is currently using sqlserver and we're trying to take a cloud turn and downsize our main sqlserver DB into a postgres/mysql/mariadb and many document stores (mongodb or google's cloud equivalent)
I've never used postgres, anyone here can vouch for it ?
I'm not sure wether or not I should ask this on stack network. It seems kind of opinion based so unrelated
I remember liking the Laphroaig 8 a lot better than the more aged ones as they were too peaty but someone gave me a bottle of qk which instantly became my favorite balance
The Picture of Dorian Gray is a philosophical novel by Oscar Wilde, first published complete in the July 1890 issue of Lippincott's Monthly Magazine. Fearing the story was indecent, the magazine's editor without Wilde's knowledge deleted roughly five hundred words before publication. Despite that censorship, The Picture of Dorian Gray offended the moral sensibilities of British book reviewers, some of whom said that Oscar Wilde merited prosecution for violating the laws guarding the public morality. In response, Wilde aggressively defended his novel and art in correspondence with the British press...