Questions tagged [select-query]
176 questions
1
vote
1 answer
MySql Query : How to select data which is not exist in last 90 days from the given date value?
I have one "User" table with fields UserId and addedDate.
I need to get data of users - added in the last month and current month and not in system for 90 days prior to added date.
User Table
Userid addedDate enddate
001 …

Madhura
- 163
- 1
- 14
1
vote
2 answers
SQL Server How to sum all fields in a row for each row of two queries and then divide them
So I have two queries that look like this:
Query1
CPT Resource 1 2 3 4 5
2017-06-11 RM1 0.000 28.000 28.000 28.000 28.000
2017-06-11 RM2 14.000 23.000 28.000 28.000 0.000
2017-06-11 RM3 0.000…

Ray
- 41
- 7
1
vote
6 answers
SQL Server How to multiply two queries
So i have two different queries as follows:
Query1
CPT Resource 1 2 3 4 5
2017-06-12 RM1 5.00 5.00 4.00 4.00 2.00
2017-06-12 RM2 3.00 6.00 4.00 7.00 4.00
2017-06-12 RM3 3.00 …

Ray
- 41
- 7
1
vote
1 answer
SQL Server: Create new query that matches prices and values from two separate queries
I have a database problem that I have no idea how to code so any kind of help will be much appreciated.
Basically it is matching different schedules with their corresponding prices.
I have two queries . . .
First query contains prices based on…

Ray
- 41
- 7
1
vote
2 answers
SQL Server: SUM multiple rows depending on a conditon
My table looks like this (I work at an energy company)
dte hub Peak Offpeak
07-04-2017 SoCo 36.19 18.23
07-04-2017 SwapBID 0.5 0.25
07-05-2017 SoCo …

Ray
- 41
- 7
1
vote
1 answer
PHP/MySql if-operator within select statement
I have database with several tables, all have one column with same name. I want to fetch data from this column that way so when it's fetched from particular table ("countries"), it has string append, otherwise data is simply fetched.
Here is my…

Annie H.
- 209
- 2
- 4
- 16
1
vote
2 answers
order by Time using current time?
I haven't knowledge about DBA .
I am a ios developer i have one question for DBA .
`SELECT StartDate,Subject
FROM tbl_Calendar
WHERE StartDate BETWEEN ` date('2017-04-25') AND ('2017-04-26')
Ex : 1
if current time is 13:30:00
give me this order…

Harshil Kotecha
- 2,846
- 4
- 27
- 41
1
vote
1 answer
Save Date from dateTimePicker into ms access database and search records between two dates
I have ms access table 'AddDate'. Two columns 'Id' -Autonumber, 'AddDate' -DateTime.
In VS 2015 I have a form where I have a dateTimePicker to insert date value.
I use the following query to insert the date:
conn.Open();string str = "Insert…

Manoj Yadwad
- 31
- 8
1
vote
5 answers
Write a SQL query to get the only Super Child records from the Table
I am struggling with preparing one SQL query that should return the expected data in one shot.
My requirement is to get the data from SQl table called JobCollection in such a way that which will return a data as highlighted in green border in below…

Charan Ghate
- 1,384
- 15
- 32
1
vote
3 answers
How to get Count as 0 when no data is found in table?
Consider I have a below table name "temp"
id | name
-----+-------
1 | AAA
2 | BBB
3 | BBB
Am getting the count of the names with below query
SELECT name , count(*) FROm temp where name IN…

Bhuvanesh
- 1,269
- 1
- 15
- 25
1
vote
10 answers
How to select a column of the last row in the table?
I have to enter a value of the last row of a table to another table.Therefore within the insert query i've used to select query to get the value i want. The query executes without any error. But it gives the 1st row of the table instead of the last…

Mike
- 1,017
- 4
- 19
- 34
1
vote
1 answer
How to get 5 record of each group with order by descending using mysql?
I want to get 5 emails of every account of Inbox folder from "Mails" Table
Table contain field of MailAccountID.
Table details:
Table Name: Mails
Folder field: FolderName
Email Account field: MailAccountID
I have tried solution suggested. It works…

Nanji Mange
- 2,155
- 4
- 29
- 63
1
vote
2 answers
How to select multiple many to many in relation with a single table
I'm currently working with database, but I've got stuck with a select query.
However, I'm not database expert.
The query should return the data from a table that has two relationships of many to many.
This is my tables Diagram that would shows the…

MST QNB
- 293
- 2
- 5
- 15
1
vote
0 answers
SUB SELECT QUERY WITH INNER JOIN giving Unexpected results
This is my query inside my stored procedure
DECLARE @branch uniqueidentifier
SELECT @branch = Branch_Id
FROM Student_Master
WHERE Student_Id = @studentid
SELECT
CompanyMaster.unique_id_company,
Job_College.College_Id,
…

mvikhona
- 101
- 7
1
vote
1 answer
How to use passed parameter as table Name in Select query python?
i have the following function which extracts data from table, but i want to pass the table name in function as parameter...
def extract_data(table):
try:
tableName = table
conn_string = "host='localhost' dbname='Aspentiment'…

nizam uddin
- 341
- 2
- 6
- 15