Bank Transaction in SQL

I have a table named BankTransaction: Create table BankTransaction ( TransactionID int IDENTITY(1,1), AccountNumber varchar(25) Not Null, TransactionDate datetime not null Default getdate(), TransactionType varchar(25) Not Null, TransactionAmount mon

SAS: PROC SQL Multiple assignments following a single CASE

I would like to know if it is possible to execute multiple assignments as a consequence of a single CASE. That is, instead of having two CASE statements, have a single CASE statement with a 'then-do-end' like structure. For example, how would I assig

Selection of the mysql line containing the user ID in a field

I am working on some type of private conversations site and I am storing conversations on a table (Messages are stored on another table) That's the format: Id: Auto incrementing Title: Varchar, represents the name of the conversation Members: Saves t

Basic SQL Query Help (does not exist)

I have 3 tables Doctor, Patient and Visit. Doctor Table has DoctorID, Name and City. Patient Table has PatientID, Name and City. Visit Table has DoctorID, PatientID, NumVisits. I am trying to retrieve all Doctors that have not been visited by a Patie

Mysql chooses between two dates will not work

I want to SELECT row BETWEEN two dates(date1 and date2) from table. I have experienced this problem but I don't know why it won't work this time. I only have 1 row in my receipt table with timestamp : 2015-05-29 22:09:44. And I have tried these synta

Get the greatest value for each group in a table

So, I have a table that is something like this... person | account | accountbalance -------------------------------------------- 1 a 100 1 b 250 1 c 283 2 a 25 2 b 199 3 a 65 and for each person, I need to find the account that has the highest balanc

Adding a column to the table with SQL

I have a SQL problem with a h2 database. I want to add a column but always get an error although I strictly stick to the syntax. Example: create table t1 (c1 bool,c3 bool); alter table t1 add column c2 bool after c1; Creating the table is no problem.

Calculation of the respective z score of several columns

I'm using a SQL query to determine the z-score (x - μ / σ) of several columns. In particular, I have a table like the following: my_table id col_a col_b col_c 1 3 6 5 2 5 3 3 3 2 2 9 4 9 8 2 ...and I want to select the z-score of every number of ever

The form elements are not read by the java ee sql

My form parameters are not loading data into the controller, I'm getting this message in the console: INSERT INTO Products (code, cateogyr_code, product_category, product_name, description, price) VALUES ('0','0','null','null','null')'0.0') The form

The request is very slow to process 200,000 additional records

I have 200,000 rows in Patient & Person table, and the query shown takes 30 secs to execute. I have defined the primary key (and clustered index) in the Person table on PersonId and on PatientId in the Patient table. What else can I do here to improv

How to get a list of months between two dates in mysql

I hve to get the list of months between two dates in mysql. For Example:My Input is From date 23-01-2013 To Date 01-04-2014 Output Should be Jan 2013, Feb 2013, March 2013, . . . Jan 2014, Feb 2014, Mar 2014, Apr 2014. SQLFiddle demo select DATE_FORM

Ignore item in bell to view

Consider a table and a view of the same table. CREATE TABLE t (a VARCHAR(10), b VARCHAR(10), c VARCHAR(10)) I have a query that runs against the table with two where clauses. SELECT * FROM t WHERE b = "foo" AND c="bar" I'd like to crea

SQL Optimize query

I am using the following query, SELECT qTermine.REISENR, qTermine.REISEVON, qTermine.REISEBIS, MIN(qPreise.PREIS) AS PREIS FROM qTermine, qPreise WHERE qPreise.REISENR = qTermine.REISENR AND qPreise.PROVKLASSE = 1 AND qPreise.VERFUEGBAR <> 0 GROUP B

SQL Server - ignore special characters

I have some special characters, mainly bullets (•) and squares (■) (unicode characters?) in a table and when I do a select I would like to ignore the special characters but still return the rest of the text. Is there an easy way to do this? ThanksTry

Group by problem with SQL counting

I have the following code: SELECT ir.[Id] ,ir.[DriverLicenseNumber] ,COUNT(ir.[ReportNumber]) As [TotatReports] ,ir.[LastName] ,ir.[FirstName] FROM [dbo].[InterimReports] ir GROUP BY ir.[DriverLicenseNumber],ir.[Id],ir.[LastName],ir.[FirstName] This

What is the actual cost of a SQL transaction?

This requires a bit of background. I'm creating a web app (ASP.NET/VB.NET with SQL Server backend) that will accept an application to receive funding, and this form has contact info fields for three people. Because the information is the same for all

Help with T-sql special sorting rules

I have a field like: SELECT * FROM ( SELECT 'A9t' AS sortField UNION ALL SELECT 'A10t' UNION ALL SELECT 'A11t' UNION ALL SELECT 'AB9F' UNION ALL SELECT 'AB10t' UNION ALL SELECT 'AB11t' ) t ORDER BY sortField and the result is: sortField --------- A10

T-sql COLLATE and Varchar (max)

When u use Varchar(max), it is 8000 chars for a variable, and around 2^32 for a column, what is COLLATE and how it affects that? ThanksCollation deterines how SQL Server sorts and compares string data (which varchar variables and column values are).

Tricky SQL - Select non-adjacent numbers

Given this data on SQL Server 2005: SectionID Name 1 Dan 2 Dan 4 Dan 5 Dan 2 Tom 7 Tom 9 Tom 10 Tom How would I select records where the sectionID must be +-2 or more from another section for the same name. The result would be: 1 Dan 4 Dan 2 Tom 7 To

Is it possible to create a temporary table on a linked server?

I'm doing some fairly complex queries against a remote linked server, and it would be useful to be able to store some information in temp tables and then perform joins against it - all with the remote data. Creating the temp tables locally and joinin

SQL Query Returning Repeated Information

I'm having an issue where this query statement is giving me repeating GoalText in the results. Any ideas? The complete query statement: Select g.GoalText, convert(nvarchar, g.GoalID) + '|' + convert(nvarchar, r.GoalReqID) as GoalID, GoalReqID from Go