Skip to content
Advertisement

Tag: database

Query BETWEEN TWO TABLES OUTPUT (MYSQL)

two table EMPLOYEE and Department EMPLOYEE’s fields are ID,Name, Salary ,DEPT_ID(foreign key to department table) DEPARTMENT’S fields are id,NAME,LOCATION VALUES OF EMPLOYEE TABLE WILL Be Values OF DEPARTMENT TABLE WILL BE Output from these table should be DEPARTMENT_Name should be alpabetically within their count If are there same Count DEPARTMENT_Name should appear in alpabetically and count will be desc order

Comparing count(*) with select for one result

I have a table tb_xyz having field1, field2 as indexed. Now I have two queries: and Assuming both queries are written to just check if this condition is met at least once. Which of them is more optimal. I tried checking for their execution times, but results were mixed, for small data. Answer The first query (SELECT … LIMIT 1)

Query based on some data multiple compare

Table: How do i bring the period when customers have max cc_limit? If the cc_limits same for customer for more than one month, take the period with highest year-month data Answer Use row_number() window function,Below should work. EDIT : To clarify why order by should be in the inline view. Scenario : When there are duplicate records for same cc_limit

Advertisement