Skip to main content

All Questions

Tagged with
1 vote
1 answer
83 views

Query to generate payroll based on attendance for a month

I have written a query to generate payroll based on attendance for a month, for about 4000 employees. It takes quite a long time to execute. Basically, what I am doing is to joining two different ...
Parvez's user avatar
  • 23
0 votes
1 answer
1k views

T-SQL query outer apply with nested subqueries

I have the following 3 tables, and I don't have the option to modify them. [Logs] table with [log_type], ...
Thomas Hsieh's user avatar
4 votes
2 answers
67 views

Acquiring earnings information

The first part of the query grabs Policy's Premiums, Effective and ...
Oleg's user avatar
  • 41
2 votes
1 answer
46 views

Collating client ratings

The code is fetching records from a table called CSAT_SUMMARY_REPORTS[driver table] but due to the filters conditions applied which needs to be checked in another ...
Soumik Dutta's user avatar
6 votes
1 answer
148 views

Report for a restaurant showing hourly sales information for a given timespan

I have been tasked with creating a report for a high-volume restaurant that shows hourly sales information for a given timespan. When generating this report for a single day, it's very quick, but when ...
Ben's user avatar
  • 63
1 vote
1 answer
57 views

Prices and contracts query

The query below is quite slow (taking about half a second). Any obvious things I could improve? The PRICES table has about 21 million rows and 30 columns while <...
BuckTurgidson's user avatar
3 votes
1 answer
44 views

Joining couples, red candidates, and blue candidates

I have 3 tables: ...
LocalHorst's user avatar
3 votes
1 answer
94 views

Archiving an SQL table of sessions and statistics

What my query is doing: I have two SQL tables and I want to copy datarows from the one table to the other table. I am doing this for statistics. The source table includes all current member-sessions/...
kentor's user avatar
  • 131
3 votes
1 answer
66 views

Join - order by vote-sum and check if user has voted

I have a vote and a comment table. Now I want to display all comments and order them by votes-sum. Sum because some votes can have a higher value than others. Therefore I want to display if the user ...
sleepless's user avatar
  • 161
2 votes
1 answer
100 views

Select Queries From Parent-Child Tables Model

I have two tables (parent-child model): Loans & Transactions. Each Loan row has multiple Transaction rows. I want to select all rows from Loans together with most recent row from Transactions. ...
levi's user avatar
  • 189
5 votes
1 answer
99 views

Library database search with multiple JOINs is too slow

I have a MySQL query which runs very slowly. I've rewritten it many times but no improvements yet. My current query for advanced search takes about 60 secs to complete. Any suggestions for improving ...
Sina Bizbone's user avatar
11 votes
3 answers
253 views

Geographic search

I have this table (inradar_ad) with almost 300k entries. I want to know why my query takes 160 secs to run. I tried limiting with ...
Patrick Bassut's user avatar
3 votes
3 answers
45k views

Inner join with first result

In SQL Server, there is two tables: Houses, and their images. I need a list with 20 houses with the first of their images (only one). I tried: ...
user674887's user avatar