Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 months ago.
Improve this question
I am trying to make a simple dashboard to get data from one sheet to show if it is greater than a week in cell B2
=QUERY('KPI 14 - 26'!A1:CC14,"select A, sum(F), sum(D), count(D)
where A is not null
AND A >= '"&B2&"'
group by A")
This code doesn't throw an error, but just doesn't display any date. If I change >- to contains it will show one weeks data. How can I fix this so that it shows all the data in weeks > week b2?
All of the data in column A on my data sheet are numbers (14 to 26)
use:
=QUERY('KPI 14 - 26'!A1:CC14,
"select A,sum(F),sum(D),count(D)
where A is not null
and A >= "&B2*1&"
group by A")
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 3 years ago.
Improve this question
I am trying to show the total number of hours imputed by each employee in a project in SAP Business One
But as a durtype in some cases it is m (minutes) and others h (hours) I get 2 rows for employee 373
Someone can think of how I can solve this without having a SELECT above to group by empid for example
Regards
You need only one SUM() & Remove durtype from GROUP BY clause :
SELECT . . . ,
SUM(CASE WHEN durtype = 'M' THEN duration / 60 ELSE duration END) AS NumberOfHoursMade
FROM . . .
WHERE . . .
GROUP BY . . . ;
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
I am working with Pharmacy drug pricing data. The data resource I am using references drugs in the following format:
NDC: 0002831517
AWP: 001539667
AWP value has this format:
Decimal, 4 digits before, 5 digits after
So I would be looking to see:
AWP: 0015.39667
Whenever I use CONVERT, I get the following error:
Arithmetic overflow error converting nvarchar to data type numeric.
Any assistance would be greatly appreciated. Thank you!
EDIT: My SQL Logic:
SELECT TOP 1000 NDC10,
CONVERT(DECIMAL (9, 5), AWPUPRICE)
FROM [TEST].[dbo].[NDC_CODES]
You can try this:
SELECT TOP 1000 NDC10, CAST(LEFT(AWPUPRICE,4) + '.' + RIGHT(, 5) AS DECIMAL(9,5))
FROM [TEST].[dbo].[NDC_CODES]
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
I have created a project in C#. In my database I have a table "Users" in which there is a field "City". Now I want to put some query that returns all the cities and how many users belongs to that city. For example there are 9 users in that table and 3 users live in New York, 3 in Chicago and 3 in Washington so the output should be:
City- New York, Records- 3
etc.
Thanks.
Group by city and then get the count of cities.
select City, count(City) as Records
from Users
group by City
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I want to write a query for count 'noOfDistribution' within a date
and by reference. for example, there are 2 in 1/5/2013.
In addition,can someone recommend some ebook/website to learn advanced skills in
query? Thanks for helping.
Answering your question:
SELECT input_Date, REFERENCE, count(*)
FROM YourTable
GROUP BY input_Date, REFERENCE
But it will result something different you pointed, since for the date 2/5/2013, it will count 6 elements for REFERENCE null
You can do something like thiss....
select count(Input_date) over (partition by Input_date,reference),* from table
By this you can find count of Particular date such as 1/5/2013 has 2 count
alternative way
select date,reference,count(*) from table group by date,reference
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
I have a data in table like this :
==============================================================================================
id idPaper Code Sequential
==============================================================================================
1A506D10-9306-495A-9E4E-7081E3D3ACDB F4CFE90D-0921-4FB7-A236-5420B0892379 0036 2
3DB0FEBF-FBDF-4768-B36A-83AF4FB53E4B F4CFE90D-0921-4FB7-A236-5420B0892379 0035 1
I want display data like this :
==============================================================================================
id idPaper Code Sequential
==============================================================================================
3DB0FEBF-FBDF-4768-B36A-83AF4FB53E4B F4CFE90D-0921-4FB7-A236-5420B0892379 0035 1
1A506D10-9306-495A-9E4E-7081E3D3ACDB F4CFE90D-0921-4FB7-A236-5420B0892379 0036 2
I run my query:
select *
from tablename
where idPaper = 'F4CFE90D-0921-4FB7-A236-5420B0892379'
and min(sequential)
but it does not work. Please help me...
Thanks...
I think you just want to sort the data. Perhaps you just want:
select *
rom tablename
where idPaper='F4CFE90D-0921-4FB7-A236-5420B0892379'
order by sequential;
You can use order by.
select *
from tablename
where idPaper='F4CFE90D-0921-4FB7-A236-5420B0892379'
order by sequential