Skip to content
Advertisement

Tag: join

Sql join with two tables max and count

i have two tables employee : employee_number employee_name salary divison_id division : division_id division_name How to Show division id, division name, number of employees working in each division that has the highest number of employees. I want to have an outcome like this : Answer

MySQL: Return a row if all joint table row have the value true

I’ve two tables as following. The relationship is What I want is to return for example for table A the record with id 1 which has a relationship with table B where all the values on table B column Delivered as true. Answer You can use group by and having: This doesn’t use table a. If you want all the

sql join without intermediate table (old database)

I’m working with a really old database and I’d like to do a simple join. Unfortunately, there is no intermediate table and it’s not possible to implement it in the near future (I know it’s really bad). The tables look like this: Expected result (for tbl_1.id = 1) How can I achieve that? I tried (didn’t work): This works but

joining temporal tables in oracle

I am looking for better solutions to a fairly generic problem with temporal tables. say we have table_a (some_value int, date_from date, date_to date) and a series of similar tables table_b, table_c, …

SQL Join based on a column value

I want to Join different tables based on column value if [dbo].[fin_FixedAssetRegister].TransactionType = ‘IOD’ then join [dbo].[sms_IssueOrderDetail] if [dbo].[fin_FixedAssetRegister].TransactionType = ‘GRND’ then join [dbo].[sms_GoodsReceivedNoteDetail] if [dbo].[fin_FixedAssetRegister].TransactionType = ‘OBL’ then join [dbo].[sms_OpeningBalanceSMSDetail] Answer You would typically use several left joins. Your question gives very little information about the underlying structures, but the idea is: THe <???> represent the names of the

What is the most appropriate logic to add rows in table

I have following table structure (simplified to make essential things clear), which lists Top 3 bank customers in each category of loan and branch of the bank. SNO column is rank of the customer, value of which is up to 3. Loan Category SNO Branch Customer Name Amount Home Loan 1 abc Piyush 10000 Home Loan 2 abc Shyam 5000

Advertisement