Questions tagged [select-query]
176 questions
2
votes
2 answers
Rearranging a string value with delimiters in a sql select query
I have a column with string value having delimiters as shown below which I use in the select part of sql query.
0040~0040~0040~0040~0040^00~00~00~01~05^100~001~010~011~015^00~00~00~01~05
individual heads are separated using '^' as shown…

iamP
- 307
- 1
- 3
- 13
2
votes
5 answers
Return True if specific value exists in table - sql
I want to create an SQL query that will return True if a specific value exists in a specific column; if not, then it will return False.
I know that I can create something like 'SELECT something FROM somewhere WHERE something'. In this case I don't…

Tal
- 337
- 2
- 8
- 21
2
votes
3 answers
sql select 5 higest values
I'm trying to select the 5 rows with the highest count value
This is my query:
string sql = "SELECT top 5 count FROM Likes ORDER BY COUNT(*) DESC";
It's just throwing an error code that
Column 'Likes.count' is invalid in the select list…
user3548681
2
votes
5 answers
MySQL Query; Combine two tables
I have two tables: Invoice
id number date client end client city vracht
1 4271 2014-5-28 ALLIN STIHO ZWOLLE 0
and Materials.
id number material thickness length width amount price
1 14271 Ocoume 10 2500 1220 …

M Zeinstra
- 1,931
- 4
- 17
- 46
2
votes
1 answer
PostgreSQL negate a numeric value in resultset
I have a query to return a resultset of decimal(30,12) type data.
SELECT sales from invoice_index;
This query is giving me output like this:
sales
------
100
-200
300
But I need an output as follow:
sales
----
-100
200
-300

ray
- 4,210
- 8
- 35
- 46
2
votes
4 answers
Select only some rows from database
I have the following query:
string Query = String.Format("SELECT ArticleName FROM tblArticles WHERE UserID={0} ORDER BY PostDate DESC", UserID);
I want to get not more than 3 different values for the 'ArticleName'.
Is it possible to do that?…

Nave Tseva
- 868
- 8
- 24
- 47
2
votes
3 answers
Set criteria to be used in multiple SQL select queries
Need to set criteria for running multiple queries, but only want to change once. For example, want to set year, period, document so that...
select * from tbl1 where tbl1.yr = year and ...
select * from tbl2 where tbl2.yr = year, and ...

Bob Bonner
- 21
- 1
2
votes
1 answer
Mqsql Query to select no of rows from each group
I want to select 3 record from each group by mysql query my table structure is like this -
id | customer | catId
---------------------
1 | Joe | 2
2 | Sally | 2
3 | Joe | 2
4 | Sally | 2
5 | Joe | 2
6 | Sally | 3
7 |…

Khoyendra Pande
- 1,627
- 5
- 25
- 42
1
vote
2 answers
Get the newest added records in the database
I can only describe the question by example..
If I have this data
use-id user-name add-date
---------------------------------------------------
2 sami 17/1/2011
2 sami …

Adham
- 63,550
- 98
- 229
- 344
1
vote
2 answers
SQL query - how to get the lines equal to 1 by count function
i have this table:
Job(j_no,position,company,salary);
and I want to get all the positions that only one company offers.
What I was trying to do was:
SELECT position, COUNT(*) AS total FROM (SELECT * FROM Job) GROUP BY
position;
and i get for…

Liran
- 37
- 1
- 4
1
vote
2 answers
Pass Null Values In A SQL Command (For Two Columns) - Adding In Foreach Loop
I want to select rows from my SQL Server table (it has 3 columns) and to display them into my Datagridview. My problem about null values. How can I pass null values? (Sometimes the first column and the second column are empty.
).
Below is my code:
…

heymycoder
- 79
- 1
- 8
1
vote
0 answers
select query gives strange characters as output
I have a problem when executing select query in android with sqlite database. In database there is a field based on sinhala characters. I populate the database using DB browser in UTF-8 encoding. I used SQLiteAssetHelper to access database in assets…

Lakshan Mamalgaha
- 11
- 2
1
vote
1 answer
Check combination of values exist in table using Select query Oracle
I have below query which is not returning expected output result. For NAME column with value='PL' it should check the data in M_LOG table with NAME and E_ID column values combination and check if this combination value exist in DIR_LOG table. If it…

Andrew
- 3,632
- 24
- 64
- 113
1
vote
2 answers
SQL query to get min, max rows
I have following sample data, I want to get min and max time of every consecutive status.
cat subcat status logtime
fruits apple 0 30-10-2017 06:00
fruits apple 0 30-10-2017 06:03
fruits apple 0 30-10-2017 06:06
fruits apple …

sk2
- 1,171
- 1
- 10
- 28
1
vote
1 answer
How to select data from table to get output in transpose or crosstab manner?
I have a table reportdata with below values :
reportdata memberCount monthname year
Assigned user 588 February 2017
Assigned user 2 January 2017
Assigned user 22 May …

Madhura
- 163
- 1
- 14