Structured Query Language (SQL) is a language for querying databases. Questions should include code examples and table structure. This tag refers to the standard language, not for questions about specific vendor extensions, like MySQL or Microsoft SQL Server, so if you think your question relates to ...

learn more… | top users | synonyms (4) | sql jobs

0
votes
0answers
11 views

MySQL query caching of inner query

I have a large query with many nested SELECT statements. A simplified version might look like this: SELECT * FROM tableA WHERE x IN( SELECT * FROM tableB WHERE x IN( SELECT * FROM tableC ...
0
votes
1answer
11 views

Divisor is equal to zero in my query

Thanks for reading my question. I have the below query. round(count(product)*100/(select sum(count(product)) FROM FACTORY WHERE TRUNC(COMPLETED) >= '01-MAR-2013' and TRUNC(COMPLETED) ...
1
vote
1answer
7 views

entity sql count null

I'm having trouble with counting null values using Entity SQL. Code in SQL: SELECT Table.City, COUNT(*) FROM Table GROUP BY Table.City and in Linq to Entities: var query1 = from g in ...
0
votes
2answers
12 views

minimizing function calls inside dynamic sql?

How do i get rid of the multiple convert functions in the following dynamic sql? IF @MediaTypeID > 0 or @MediaGroupID > 0 BEGIN SET @SQL = @SQL + 'INNER JOIN (SELECT lmc.ID ...
0
votes
2answers
16 views

SQL call a SP from another SP

Can I please have some help with the syntax of a SP in SQL. Here is my code: CREATE PROCEDURE usp_GetValue ( @ID VARCHAR(10), @Description VARCHAR(10) ) AS BEGIN return @ID + ...
0
votes
1answer
18 views

unable to pass float value as sqlparameter

My query is like this DataSet ds = SqlHelper.ExecuteDataset(GlobalSettings.DbDSN, CommandType.Text, "SELECT TOP 1000 [ID],[Project]," + "[Owner], " + "[Consultant], " + ...
1
vote
3answers
28 views

Find Duplicate Rows/Records from Table

Here is my table structure, Im try run query $sql = mysql_query("SELECT content,niche, COUNT(content) TotalCount FROM table_name GROUP by content HAVING COUNT(content)>=2"); I i think is give ...
-2
votes
3answers
40 views

SQL - ORDER BY not working properly?

SELECT test_column FROM test_table ORDER BY test_column gives me this: 1 12 123 2 3 Why not: 1 2 3 12 123 @JosephPla You got the point, thank you. How can I sort strings like ...
0
votes
0answers
17 views

SQL get Primary Key from SP

With SQL, when inserting values into a Table from a SP, is it possible to get the value of the Primary Key before the values are added to the Table?
0
votes
0answers
13 views

entity sql top with ties

Is there an equivalent for "WITH TIES" in Entity SQL? I'm trying to select top 2 values (with ties), and in TSQL I'd do it like: SELECT TOP 2 WITH TIES... In EntitySQL I can use TOP clause like: ...
0
votes
1answer
12 views

SQL Server Powershell

I have written a powershell script : I would like to keep connection open for 6 hrs but i don't know how to do ,iam using do until but its going unending i would like to close connection after 6hrs, ...
-1
votes
2answers
25 views

SQL Simple Script

Can I please have some help to make a simple SQL script that returns a value depending on the two parameters passed into the script. For example, if I pass the values "1" & "Test" then the value ...
-4
votes
1answer
15 views

Column is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause

Column 'first.Bname' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause. My sql query is SELECT Bname,DPID+'-'+BACCTNo as LFNO, ...
0
votes
2answers
24 views

Adding a stored procedure to a database

If I create a database called MyDatabase and then wish to add a stored procedure to this database, do I have to specifically reference this database when running the SQL query for the stored procedure ...
0
votes
2answers
25 views

Generate a list of numbers equal to the number of rows in a table

I have table with 7 rows; I want a query which will return the values shown in the second query, using the using total number of rows in the table, without using the table name. CREATE TABLE IF NOT ...

1 2 3 4 5 9570
15 30 50 per page