Skip to content

How to simplify nested select in where clause?

I have 4 tables EMPLOYEE, COMPANY, WORKS and MANAGES. The tables are defined as follows- I need to find all the employees who live in the same city as the company for which they work. So far I have done this. It’s working fine. But I want to know is there any simpler way to do this query? Answer You

C# win forms app hangs

The following code is for reading from an Access DB and transferring to a SQL DB. Can anyone tell me why this code just hangs after it is run ? I have a label that should change telling me the row that is being processed but the Form just sits and becomes unresponsive once I have clicked the button. Everythin…

How to compare two columns in the CASE statement

I have two columns Speed_A and Speed_B. Now I will compare both columns and will select the higher one in a new table. Something like this: How does it work? Answer Assuming your speeds are numerically typed you might get this as easy as: Your ELSE will only occur, when A and B are equal, In this case it does…

SQL Query Where Date = Today Minus 7 Days

I have a SQL table of hits to my website called ExternalHits. I track the URL as URLx and the date the page was accessed as Datex. I run this query every week to get the count of total hits from the week before, and every week I have to manually change the “between” dates. Is there some way I

Presto create table with ‘with’ queries

typically to create a table in Presto (from existing db tables), I do: But to make my code simple, I’ve broken out subqueries like this: Where do I put the create table statement here? The actual query is more complex than the above so I am trying to avoid having to put the subqueries within the main qu…

SQL – listing members on enrolled classes

I am trying to figure out why this isn’t working. I am trying to select each member’s names and the classes that each member is enrolled on together with the class trainers name. This is what I have at the minute: Any help or tips would be appreciated as I am still learning SQL. Extra info: enrolm…