Write an SQL Statement

This project is to write a simple SQL statement. The data (and database structure) for the SQL statement is located at [url removed, login to view]

Basically, the SQL statement needs to return the signalid from the tradesignals database. The only variable that is passed in from the outside is the acct_id filed. It needs to have the following criteria:

1. The lowest signalid needs to be found for a given account id where the cmd is less than 6 and the same signalid is not already inserted into the usersignalx table for the given account id and there is no associated signal (found by associating the signalid field in the first record with the assoc_signalid field in the second record) where the cmd in the second record is equal to 6 or 7.

2. The lowest signalid needs to be found where the cmd is 9 and the signalid is not already inserted into the usersignalx table for the given account id.

3. The lowest signalid is found where the cmd = 6, 7, or 8 and there exists a corresponding record (linked by signalid = assoc_signalid) where the record for the assoc_signalid is in the usersignalx for the passed in acct_id. However, if the there exists a cmd = 6 or 7 for the same assoc_signalid, the cmd = 6 or 7 should be returned (lowest of them first is fine).

The lowest of 1, 2 and 3 should be returned in the statement, if possible.

In other words - some of the tradesignals are records on their own, and some later ones are associated to an earlier signalid (based on the assoc_signalid). The goal is to find the lowest standalone one (with a cmd of less than 6) that is not already recorded by the user (thus in the usersignalx) or find the > 6 < 9 signalid records that the user already recorded.

The goal is to write efficient SQL, but if the SQL statements need to be broken up, then that is okay.

Speed is important as well as utilizing the proper keys. Make sure the database structure has the keys defined to optimize the SQL statement. No database or structure modifications should be made (besides key recommendations).

Skills: SQL

See more: key data structure, key criteria, find the words and write, sql less than, write com, write some sql for a project, utilizing, sql, sql based, statement structure sql, sql optimize, filed, simple write, simple sql statements, standalone data, simple data structure project, data structure simple project, database broken, data write, sql simple project, standalone database, database table structure, project based sql, simple project sql, signal project

About the Employer:
( 149 reviews ) Platte City, United States

Project ID: #569521

Awarded to:


Dear Customer, Let's start. Regards, Crispy..

$30 USD in 1 day
(1 Review)

check pmb for details

$44 USD in 0 days
(1 Review)

12 freelancers are bidding on average $53 for this job


Hello, please see PMB

$60 USD in 0 days
(28 Reviews)

Hello, We have 9+ Yrs of experienced in .NET /PHP [url removed, login to view] did 200+ Web /Desktop [url removed, login to view] have 5 yrs Experieced (SQL SERVER) DB [url removed, login to view]

$45 USD in 1 day
(1 Review)

Hello,we are experinced with .Please check pmb for more [url removed, login to view]

$50 USD in 1 day
(8 Reviews)

I am expert in MQL4, SQL and VB. Check PMB for details.

$50 USD in 0 days
(13 Reviews)

Exceptional quality & Quick work. Please refer to Profile & PMB for details. Thanks FAZ

$35 USD in 0 days
(3 Reviews)

Will give you with in hours, i am pretty much confident on giving finetuned SQL statement on your [url removed, login to view] you need me please shoot PM. thx for your time.

$60 USD in 1 day
(0 Reviews)

I have been working in SQL and PL/SQL for around 5 yrs. I have strong experience in performance tuning.

$30 USD in 1 day
(0 Reviews)

Hello Dwmcqueen!! We are SolutionBytes ready to write this statement. We have umpteen programmers and developers in sql. But we need to discuss further so that we could start asap. Please check our profile that will le More

$140 USD in 2 days
(0 Reviews)

Hi, I can do this job. Have written query for the 2nd one. Have a look. If needed, I can do for the 1 and 2 also...But pls give me the table names,,,all such details. Bid amount: Negotiable. For second one, More

$30 USD in 1 day
(0 Reviews)

Hi Can I start working? Read PMB

$60 USD in 1 day
(0 Reviews)