I am trying to get the following query to display the results in alphabetical order by City except for the fact that I want "Berlin" to appear at the top of the list
So the results would look something like
Berlin
Algeria
Australia
Fiji
Greece
...
Hope that makes sense,
I currently have the following...
SELECT CompanyName, City
...
tableA contains {id, fromPos not null, toPos}
fromPos and toPos denotes a range of values for a particular row
toPos is a nullable field
and has the following values
tableA (1, 5) // means any position greater than or equal to 5
tableA (2, 5, 10) // means any position between 5 and 10 (inclusive)
tableA (3, 6)
tableA (4, 7, 9)
...
I have following problem where I have to group different transactions into timeslots. Suppose you have a table with records which contain an entry datetimestamp. These records are created by users (operators) who work in different shifts
Shift 1: 5 - 13h //
Shift 2: 13 - 21h //
Shift 3: 21 - 5h
Now I want to have a flexible query whic...
I have a SQL Query giving me a list of double records in my database.
select periodid, itemid from periodscore
group by periodid, itemid
having count(*) > 1
This works as expected, but now I would like to retrieve additional fields of these records (such as date last updated etc). So I tried:
select * from periodscore where period...
I have created a SQLite database on my PC. I have imported it into my assets folder in the project directory. How do I access it from my Android application?
...
Hi.
Given an input of the format (currently a flat file):
Name, StartDate, EndDate
with sample data
like
Peter, 2010-09-01, 2010-09-04
I was wondering which SSIS task I could use to split this single row into a row per day:
Peter, 2010-09-01
Peter, 2010-09-02
Peter, 2010-09-03
Peter, 2010-09-04
I know I can probably do it with a s...
How to execute one Stored Procedure inside other Stored Procedure?
NOTE: Both Stored Procedure's reside in different servers
...
Hi, I have written the following query so as to select the rank of each customer and show it with other information in the output.
use northwind
go
select
Employees.EmployeeID as ID,
FirstName+' '+LastName as Name,
DENSE_RANK() over (order by SUM(Orders.OrderID)) as [Rank]
from
employees
inner join
orders
on
Employees.EmployeeID...
I'm trying to query some XML in SQL Server but am having difficulties:
Here is some sample XML:
<BaseReport>
<Parties>
<Party>
<SubjectType>
<ListItem Name="SubjectType1Name" />
<ListItem Name="SubjectType2Name" />
</SubjectType>
</Party>
<Party>
<SubjectType>
<ListItem Name="SubjectType...
I have a large statement:
SELECT
a.user_id, a.user_name,
s.name, s.value,
d.default
FROM
accounts a,
settings s
LEFT OUTER JOIN default d ON ( d.name = s.name )
WHERE
s.user_id = a.user_id;
The problem is that settings contains a large amount of entries and I need to pick the one with the highest ID. I can ...
Hi all,
I'm using Oracle DB and I would like to write a SQL query that I could then call with JDBC. I'm not very familiar with SQL so if someone can help me, that could be great ! Here is the problem. I have a table MY_TABLE wich contains a list of another tables, and I would like to keep only the nonempty tables and those that their na...
Using Pervasive SQL, I have a result set:
Tp_No Name State Eff_Date Actual Billed
1006 ABC TN 2006-07-01 .1 .5
1006 ABC TN 2008-02-15 .27 .6
1006 ABC TN 2010-09-01 .37 .7
1022 Widget TN 2006-07-01 ....
I need to return a parent child relationship from 3 tables which are for bottom, mid and top level respectively. Easy stuff so far, and done already:
SELECT -1 ParentID, ID + 100000 ID, txtName Value from tblLevel1
UNION
SELECT Level1ID + 100000 ParentID, ID + 50000 ID, txtName Value from tblLevel2
UNION
SELECT Level2ID + 50000 ParentI...
Hello,
I am using MSAccess and am using this code
[Text;HDR=''No'';FMT=''Delimited'';Database='+ExtractFilePath(Location)+'].'+ ExtractFileName(Location);
What are the different options I can use for FMT? I have seen:
Fixed
Delimited
TabDelimited
...
Edit: more code
Dim oControl As New Forms.Control()
Using types As New DataSet
With oDal
.Parameters.Clear()
.Execute(sql, types)
End With
Wi...
Using Firebird:
I want to select a random entry in the table if the first SQL query returns 0 rows. Is there anyway to combine these two queries?
SELECT * FROM table WHERE cond=1;
SELECT FIRST 1 * FROM table ORDER BY rand();
Im using ExecuteNativeQuery on the java-side which takes basic SQL statements. Sadly, If-Else statements don'...
Many database connection pooling libraries provide the ability to test their SQL connections for idleness. For example, the JDBC pooling library c3p0 has a property called preferredTestQuery, which gets executed on the connection at configured intervals.
Many example queries I've seen are for MySQL and recommend using SELECT 1; as the v...
Hi all,
I'm trying to establish a temp table for a running inventory demand report in SQL 2008. I can get the results that I am looking for until I hit an invoice with multiple lines. Here is the code so far:
--Gather Current Order Data
DECLARE @b TABLE ([Planned Shipment Date] DATE, [Order] VARCHAR(15), [Line Number] VARCHAR(15), [L...
Based on this question:
http://stackoverflow.com/questions/1310649/getting-a-modified-preorder-tree-traversal-model-nested-set-into-a-ul
The logic bellow is used to build an ordened list, but how to do the same with an array?
I want to build a nested array.
// bootstrap loop
$result = '';
$currDepth = -1; // -1 to get the outer <ul...
Client wants a field in the mysql DB to be composed of a prefix, the year, and a counter that resets each year. PREFIX 2010 0001 ... PREFIX 2010 0734, then PREFIX 2011 0001. Are there any mysql tricks to make that happen or do I keep track of the largest number used for each year. Any thoughts appreciated.
...