|
Sir i want to fetch data from a table where status in Debit and Credit.So i want amount saprate with debit and credit. and its diffrence.Please help me
|
|
|
|
|
There's no way anyone can help you based on that description.
You need to show us the structure of your table, the sample input, and the expected output.
You also need to show us what you've tried, and tell us where you're stuck.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
How can we help?
Social Media - A platform that makes it easier for the crazies to find each other.
Everyone is born right handed. Only the strongest overcome it.
Fight for left-handed rights and hand equality.
|
|
|
|
|
So I'm new to MongoDb; well I have about a year of experience, and I'm trying to write my first really complicated read.
What I'm trying to do, is grab a Brand by name, then all the products that match the brand name, then go through the products and get all the different distinct category names. Finally, grab the categories that match the list of category names.
So I'm just down to the final part, I have a list of distinct category names that are available by an enumerator, and I have a list of categories, I just can't figure out how to do the final part. I don't know what to call it either to search for help. I thought about a loop going through the categories, but I'm not sure how to unpack my distinct list of category names. Or perhaps the authors already thought of this and wrote something.
The categoryDistinct works.
categoriesSelected , my new list of categories
categories , a list of all the categories
var brandTask = _context.Brands.Find(b => b.Name == brandName).FirstOrDefaultAsync();
var productsFiltered = _context.Products.Find(b => b.Brand == brandName).ToList();
var categoriesDistinct = productsFiltered.GroupBy(c => c.Category).Select(x => x.FirstOrDefault());
var categoriesSelected = new List<Category>();
var categories = await context.Categories.Find( => true).ToListAsync();
var productFilter = Builders<Product>.Filter.Eq("Brand", brandName);
var productsTask = _context.Products.Find(productFilter).ToListAsync();
await Task.WhenAll(brandTask, productsTask);
return new GetBrandPage { Brand = brandTask.Result, Categories = categoriesSelected, Products = productsTask.Result };
If it ain't broke don't fix it
Discover my world at jkirkerx.com
|
|
|
|
|
I came up with this and it works so far. A combination of Mongo and Linq.
Changed some categoryDistinct to productDistinct , better name.
I actually didn't think it would work.
var brandTask = _context.Brands.Find(b => b.Name == brandName).FirstOrDefaultAsync();
var productsFiltered = _context.Products.Find(b => b.Brand == brandName).ToList();
var productsDistinct = productsFiltered.GroupBy(c => c.Category).Select(x => x.FirstOrDefault());
var categoriesSelected = new List<Category>();
foreach (var product in productsDistinct)
{
var cx = _context.Categories.Find(c => c.Name == product.Category).First();
if (cx != null)
{
categoriesSelected.Add(cx);
}
}
var productFilter = Builders<Product>.Filter.Eq("Brand", brandName);
var productsTask = _context.Products.Find(productFilter).ToListAsync();
await Task.WhenAll(brandTask, productsTask);
return new GetBrandPage { Brand = brandTask.Result, Categories = categoriesSelected, Products = productsTask.Result };
If it ain't broke don't fix it
Discover my world at jkirkerx.com
|
|
|
|
|
Hi,
Working in a time tracking program, I've thought of separating results in pages.
I think of making a specific SQL query to count the amount of total registers with the applied filters, then call the another SQL query with LIMIT clause to be able to define from which record I want to start showing the results and the amount of results.
Is there any better way to do it?
Thank you in advance!
|
|
|
|
|
|
I have a column and i need to find in which table this column exists throughout whole DB Using query
|
|
|
|
|
The column name is not unique. The column with a particular name may be in every DB table.
And BTW, what DBMS are talking about: MS Access, SQL Server, Oracle, PostgrSQL, ...?
|
|
|
|
|
Assuming Sql Server:
SELECT SCHEMA_NAME(schema_id) [Schema Name]
,t.name AS [Table Name]
FROM sys.tables AS t
JOIN sys.columns c ON t.OBJECT_ID = c.OBJECT_ID
WHERE c.name = 'ColumnName'
|
|
|
|
|
How do i browse to let's say 10 records before the last one? Code below:
Dim con As String =
"User=SYSDBA;PASSWORD=masterkey;Database=/DATABASE/TIME_DBS/TC_SHPIRAG3ST4.gdb;Datasource=192.168.2.78;Port=3050;Dialect=3"
Dim conexiune As FbConnection = New FbConnection(con)
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
conexiune.Open()
Try
Dim sCmd As FbCommand
Dim sql As String
Dim ds As FbDataReader
sql = "select * from RT_TIME ORDER BY RTTI_COUNTER desc"
sCmd = New FbCommand()
sCmd.Connection = conexiune
sCmd.CommandText = sql
ds = sCmd.ExecuteReader
ds.Read()
TextBox1.Text = ds("RTTI_BIT_POS")
Label1.Text = ds("RTTI_HOOK_POS")
ds.Close()
conexiune.Close()
Catch ex As FirebirdSql.Data.FirebirdClient.FbException
MsgBox(ex.ToString, vbCritical, "DB Error")
End Try
End Sub
modified 22-Sep-19 23:38pm.
|
|
|
|
|
|
thanks, i didn't find the right information
|
|
|
|
|
nevermind, found it: sql = "select FIRST 1 SKIP 10 * from RT_TIME ORDER BY RTTI_COUNTER desc "
|
|
|
|
|
Hi!
We are re-writing existing access DB process into Oracle.
With that said, we need to calculate averages upon request. The data is loaded everyday through datawarehouse. We would need to store amount value everyday, maybe into another table, and be able to calculate the average upon request? Just have a table listing the key fields in addition to date and amount? with date and amount changing everyday?
Is there any other option to do this? If it were SQL server, I could have explored the SSIS packages. Not sure in Oracle.
thank you!
|
|
|
|
|
You ask "your" users what sort of queries they "typically" deal with; and (re)design your data warehouse based on that.
This isn't something you base on opinions gathered in the wild.
The Master said, 'Am I indeed possessed of knowledge? I am not knowing. But if a mean person, who appears quite empty-like, ask anything of me, I set it forth from one end to the other, and exhaust it.'
― Confucian Analects
|
|
|
|
|
how to make number 56,500,51 in MySQL
I tried to make a function in MySQL like this
CREATE FUNCTION `fTITIK`(number double(8,2)) RETURNS VARCHAR(255) CHARSET latin1
DETERMINISTIC
BEGIN DECLARE hasil VARCHAR(255);
SET hasil = REPLACE(REPLACE(REPLACE(FORMAT(number, 2), '.', '|'), ',', '.'), '|', ','); RETURN (hasil);
END
hen when it starts it only appears 56,500 while the numbers that are behind the comma do not work
any suggestion?
what should I fix?
modified 17-Sep-19 23:58pm.
|
|
|
|
|
It looks like the value represents a floating point number (or currency.
If that's the case, don't store it as a string. The app that uses the data is responsible for correctly formatting the value for display purposes.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
|
Do your data formatting in the user interface (that includes reports). NEVER do it in the database and as John said never store your numbers as strings ALWAYS use the correct data format. This also applies to dates, store them as DATE or DATETIME, never as strings.
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
|
|
There are umpteen reasons why a database may start having performance issues - it is unlikely to be your unchanged code!
This post lists some of the troubleshooting steps you can try to either find out what is wrong and/or just do some housekeeping that should help [SOLVED] SQL Server database slowness troubleshooting - Spiceworks[^]
|
|
|
|
|
Found it...
Between 2 recreations and data repopulation.. someone one changed the primary key of many tables that were used in joins from CLUSTERED to NONClUSTERED index
That seemed like a good idea at the times, they said....
|
|
|
|
|
Check the execution plan. Check that you have the correct indexes on the tables. Try running Brent Ozar's First Responder Kit[^] on the server to see if there are any obvious errors.
You mention that the size of the data has increased. Does it now exceed the server's available memory? If it keeps having to go back to disk to load the data, then that can dramatically slow things down. Especially if the data isn't on an SSD.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|