sql

SQL statement filter result

I need to filter the SQL query result according to 3 conditions: 1. Location 2. Doctor Name 3. Specialty Name Below is the sql query if all 3 conditions are not empty: if (location != "" && doctor!="" && specialty!="") select Location, ... from clinicdoctors where Location = @Location and DoctorName = @DoctorName and SpecialtyName = @...

How to give select digit after decimal point?

In database there is column amount which datatype is money. I want to select that row only with two digit after decimal. for this how to write the query? My query is like this: SELECT AMOUNT FROM DETAIL_PAGE. Please modify this query so that it select two digit after decimal point. ...

HSQL access from both Java and Ruby?

Is it possible to access a local HSQL database from Ruby as well as from Java? (separately of course, not concurrent) The Ruby SQL toolkit called Sequel, for example, claims to have "adapters" for JDBC, so I think the answer is yes, yes? =) If the answer is "kind of" or something, is there a better RDBMS that would allow straightforward...

Why Transaction does not work on Identity column?

Why transaction does not rollback Identity column. I have a table named "DetailReports" which has one Identity column. There are some SPS which manage data of DetailReports. Transactions are there based on condition now issue is that when we call rollback of transaction then we are not getting rollback of identity column. If its the natu...

error in sql query

I am writing an query in sql and getting an error: Invalid use of group function What does it mean? In my query, where clause is given below: select c.name,s.contact,s.number from list c , senior s where c.id = s.id AND c.name = 'Abg' AND c.state ='qw' AND MIN(c.dob); Basically, I have 2 files and I need to find the younger custome...

SQL engine for only SELECT statment - hand written parser in c++

Hi, I am a newbie of compilers, but i got a project SQL engine - for only select statement. For this i have to use only hand written parser and engine. I studied the samples of LL(k) grammar and recursive descent techniques(suggested by stackoverflow for writing parser by hand). But in any of the samples, didn't find the way to construc...

What is the use of "Union all" ?

I am not asking difference between them, my question is when we need to use "Union All" ? ...

help in solving a problem in sql server

I have aquestions from you. Does SQL server have any features so we can limit a field to fill with just specific values? For example assume that you have a field named "Name" then we want SQL just let us to fill this field with the following values: "Bella", "Jack", "Rose". is there any featues to do it? please guide me. thanks ...

mysql query on dob

If DOB is given in this porder- 1853-03-12 , then how do we find the youngest person from table bases on this type of data. If the year is same but month is different for 2 persons. I tried MIN(dob)- it gives me the oldest person and When I tried MAX, it gives me nothing. ...

query to select distinct

Hallo Friends, I need a query to throw an error message on comparison with table temp_invoice. It should compare the field [Task resp#] , against the [PB-ID] field in PB_Responsbility table for customer = 3D temp_invoice format Concession Number [Task resp#] TH-123 12345 TH-014 98065 TH-12...

How do I group by day when the date is stored as a long?

I need to group a query by day but the date is stored as a long, how do I do that with SQL? I need this to work across multiple vendors - oracle, db2, sql-server & mysql. The long is milliseconds, generated by java.util.Date.getTime() - which I can't change. ...

SQL query - comparing two items on distinct item

Hi I'm a newby to SQL code and wondered if it was possible to get an output of:- **EVT John Paul Difference** A1 1 2 -1 A2 2 3 -1 From the below data source. **EVT PERS RANK** A1 John 1 A1 Paul 2 A1 Ringo 3 A1 George 4 A2 Ringo 1 A2 John 2 ...

SQL cell wise trigger

Hi, Can a specific cell wise trigger be created. Or Is IF UPDATE(COLOUM) where OTHER_COLOUM like 'JT' 's equivalent present in MSSQLSEVER2008 ? ---EDIT after getting 2nd answer--- IF not UPDATE(CurrentNo) --// Wanted to do like this : where series ='JT' return IF not EXISTS ( SELECT 'True' ...

Debugging SQL Server queries

I have a view which has started causing the following error: Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value 'R1500051' to data type int. The problem is, the query is quite big and complex (several sub queries, joins and function calls) and I have no idea where that error is actually coming from....

mysql database populate

How should we treat the data if they have no values in it. I mean, at some places, they have no value. Should we populate it as it or should we write something at that place? ...

SQL and PL/SQL Tutorial

Hi, Where can i find good tutorial for SQL,PL/SQL and also interview questions. ...

Distinct with select *

Is it possible to use select * with distinct or write easily something that has the same impact? I need to select all columns from a table with distinct value, but listing all the columns in select clause would be nerve-breaking because the number of columns is over 20! ...

Make a field monotonic across all rows

Hi, I have table in my sql server database which I want to convert to PK column To do that I want to change value of each row in this column to 1,2,3 ... Could You write T-Sql query for that task ? Thanks for help begin state: Id | Name | ---------- 1 | One | 2 | Two | 2 | Three| x | xxx | result: Id | Name | ---------- 1...

NHibernate not outputting SQL to console

I have configured NHibernate to output the SQL it generates to the console. I have added the following to the app.config of the DLL containing the integration tests I want to run from NUnit: <configSections> <section name="nhibernate" type="System.Configuration.NameValueSectionHandler, System, Version=2.0.0.0, Culture=neutral, Pub...

passing a parameter into a subquery

Hi, i was wondering if it is possible to pass a parameter into a select subquery. What i want to do is collect some product data from one table and then crossref the weight of the item to it's carriage cost in a shipping table to return a cost. something like: select cataloguenumber, productname, (select shipping.carriagecost...