Hi,
I have a table containing the scores of my game
CREATE TABLE Scores
(
PlayerName varchar(50),
LevelId integer,
Score integer,
Difficulty integer
);
and I would like to always limit the number of score entries to 10 elements (for a specific level, and difficulty)
So when the score table has 10 entries (for a specific lev...
Hello Guys,
Do you think having TRANSACTION around every sql statements in stored procedures is a good practice? Just about to optimise this legacy application in my company, one thing I found is that every stored procedures has BEGIN TRANSACTION. Even a simple select and Update statement has one. I thought it would be nice to have BEGI...
I've modified my previous code for login.
package log1.log2;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class Login exte...
I am using SQL Server 2008 and need to alter a large number of columns across many tables from decimal(9,3) to decimal(12,6)
The issue I currently have is that some tables have several indexes on these columns and the alter statement fails due to the index.
Is there a way to alter the column without losing the index?
I am altering the...
I am building a system that stores articles and tags that categorize the article. Standard stuff, similar to how this website does it. Now my question is whether I should store the tags on a separate table that just contains tags and article ids or store the tags on an extra column in the articles table. My first instinct would be to nor...
how can i get students grades using these 2 tables?
CREATE TABLE [dbo].[Grade](
[ID] [int] NULL,
[From] [int] NULL,
[To] [int] NULL,
[Grade] [nvarchar](50) NULL
) ON [PRIMARY]
CREATE TABLE [dbo].[Students](
[ID] [int] NULL,
[Name] nvarchar NULL,
[Score] [int] NULL
) ON [PRIMARY]
...
Hi,
I'm using a generic system for reporting which takes data from a database view (SQL Server 2005). In this view I had to merge data from one-to-many relations in one row and used the solution described by priyanka.sarkar in this thread: Combine multiple results in a subquery into a single comma-separated value. The solution uses SQLX...
Hi everybody , I want to retrieve top 5 rows returned by this query. How to do this
select COUNT(trippackageID), trippackageid
from tbl_holiday_booking
group by trippackageID
...
hi,
i've got a sql-query, executed against non-ax-tables ( partially at least ) from x++ via odbc.
the sql-query-execution-plan suggests to add an index to the referring ax-table, eg:
CREATE NONCLUSTERED INDEX []
ON [ ([field1])
INCLUDE ([several fields])
i remember it wasn't a good idea to create any of those indices via management-s...
Hello, I have a question addressed to sql guru.
There are two tables with almost identical structure.
Based on parameter passed into the stored procedure I need to collect data from one or another table.
How to do that in a best way?
Please do not suggest to combine those tables into single one - that is not appropriate.
I did it ...
Example:
SELECT `film_id`,COUNT(film_id) AS COUNT FROM films_genres AS FilmsGenre
WHERE genre_id In (4)
GROUP BY film_id,COUNT
HAVING COUNT = 1
return:
film_id | COUNT
7 1
6 1
But I want it to return:
film_id
7
6
How do I return only 1 colomn?
...
I need to split an address which is a single string into multiple strings. Below are the requirements to for the pl/sql procedure that splits up the address into the corresponding address lines. The parameters of the procedure are:
create or replace procedure split_address
(
address in varchar2,
al1 out varchar2,
al2 out varchar2,
al3 o...
Basically I have a asp.net that I need to display an XML document (straight xml, with the tree nodes) I have the sql statement which returns the row names and each one of their values. Just wondering how I should go about doing this?
SQL Server 2008, my query is just a select * from offices, my results is "1","New York","New York City"...
Lets consider I have a table 'Tab' which has a column 'Col'
The table 'Tab' has this data -
Col
1
2
3
4
5
If I have a set of values (2,3,6,7). I can query the values that are present in the table and the list by suing the query
Select Col from Tab where col IN (2,3,6,7)
But, if I want to return the values in the list that are no...
I'm having difficulty working out how to 'error handle' as such the following SQL.
As part of my SELECT statment I have
((sp.sp_retailprice - sp.sp_wholesaleprice_l1) / (sp.sp_wholesaleprice_l1)) as 'calc test'
Which subtracts one column from another then divides the result by the column sp_wholesaleprice_l1.
However, the values of...
I have an object, say a note, whose parameters I want to save in a table(content, size, width, height, etc).
With having the sql string updateNotes:
UPDATE NOTES
SET
CONTENT=@content,
POSX=@posX,
POSY=@posY,
COLOR=@color,
ORIENTATION=@orientation,
HEIGHT=@height,
WIDTH=@width,
AUTHOR=@autho
WHERE S...
Can you do somwthing like this in postresql?
select min(column1, column2) as Min, max(column1, column2) as Max from mytable;
...
I have to run a very simple query like this in SQLite3.
INSERT OR REPLACE INTO tblPhoneList(Phone, PeopleId, StorageType) VALUES('+91912345789', '1','1');
But whatever I do, the number is stored as 91912345789. The + prefix is ignored.
The field Phone is a String. Why does it ignore the + prefix?
Is there anyway to avoid this?
P.S. T...
I have a .sql file that was created by postgresql a while back. I now want to import this file onto a windows machine running postgresql.
How do I do this. The file is about 1.5gb.
...
So here's what the table looks like
--------
| field1 |
|========|
| 1.2 |
| 1.7 |
| - |
| - |
| 1.3 |
the dashes are actually blank fields
My current SQL statement does a simple "ORDER BY field1" which puts the blank ones on top, however I want to get the numbers on top, and put the empt...