« first day    last day (4318 days later) » 

1:42 PM
sql query fire in bottom up approch
 
Excuse me?
 
what?
 
What did you mean by that?
 
i ask that sql query fire in bottom up approach ??????????first of all it see which part select or from or where
i have big query which i can not understand so i ask
 
That question doesn't make sense...
 
1:51 PM
if u r ready to explain then i put here.
"select a.name,"
+ "("
+ " select sum(qty) from"
+ " ("
+ " select opening_balance as 'qty' from accounts where id=a.id union all "
+ " select sum(amount) from contras where debited_party=a.id union all "
+ " select sum(-amount) from contras where credited_party=a.id union all "
+ " select sum(amount) from debit_notes where debited_party=a.id union all "
+ " select sum(-amount) from debit_notes where credited_party=a.id union all "
+ " select sum(amount) from credit_notes where debited_party=a.id union all "
 
There is really no 'order'. I think the answer you are looking for is: From first, including joins. Where second. Select third.
 
ok
 
@prjndhi What version of SQL?
 
sorry it is sqlite.there is not chat room for sqlite so i ask here
ok
what is the advantage of stored procedure over parametrized query ?
 
sprocs give you more power and security, but only if you use them right.
 
2:05 PM
i say it in my viva exam and i will get good marks from teacher very very very thanks
 
@prjndhi That is a horrible query to begin with.
Refactor it to use more joins. A series of subselects is worse than properly joined subqueries.
 
yeah,i am trying to understand it according to @KendallFrey said
 
2:33 PM
Honestly, the layout of the data does not seem very coherent.
In other words, if all you have is a single ID (the Party) to link all that together, then something is DEFINITELY wrong. You haven't given yourself enough join options to get this kinda data efficiently.
If, on the other hand, you can link it based on some sort of transaction ID, then you can get the results of all transactions for a particular party, then get the sum of all transactions for each party.
 
Denormalized databases give me the shivers.
 
@KendallFrey Agree.
If you can't get aggregate data from a few joins, then the schema is WRONG.
Databases are supposed to be a coherent collection of data, that lays it out in a manner that is easy to not only get the results, but run any sort of statistical/aggregate calculations without much trouble.
 
It is surprising how much OOP knowledge helps you when designing a database.
 
Exactly.
Not only that, but separating transactions into debit/credit tables is such a horrible offense, because now you have to remember that the credit tables are a negative amount (multiply by -1) as opposed to using a ledger based schema.
I was the query monkey at my last place, so I was handed all report requests. Believe me when I say that if the data is logically laid out, it's really easy to get the data you need out.
 
 
5 hours later…
7:21 PM
anyone in here?
 
Welcome!
 
hi
 
Do you have a question, or are you hankering for discussion?
 
yeah i posted a question stackoverflow.com/questions/10658006/… but people are having a hard time figuring out what the problem is
so i thought you guys might know :P
 
Well, I'm not a SQL guru, so I don't really know.
 
7:31 PM
k :)
 
8:31 PM
hey
how to count number of rows in the table with where command in the same query.
 
hi
Can you do it without? There isn't much of a difference.
 
example i want to know how many departments are there in student table
I am using this query but it is always returning 1
SqlCommand cmd1=new SqlCommand("Select count(*) from Student where DepartmentName = 'DepartmentOfElectricalEngineering'");
cmd1.Connection = conn;
studentdata[4] = cmd1.ExecuteScalar().ToString();
 
Does it work as expected without the where?
 
yes
but i need to know only rows where the department is DepartmentOfElectricalEngineering
 
And you're sure there are more than 1 DepartmentOfElectricalEngineering records?
 
8:36 PM
yes
 
@alternatefaraz What are you expecting? What are you actually getting? If you replace the select count(*) with select * do you still get the desired results?
The desired number of rows, that is.
 
but i want to count the rows
 
Yes, I know, but just make sure you're getting the desired results first.
 
yes i am getting it
 
Then count(*) should give you the correct results.
Which takes us back to the original question: What are you expecting? How does it differ from what you're actually getting?
 
8:49 PM
i want the number of rows only number not the exact row
 
OK, you seem to be missing the point. What result are you getting when you run Select count(*) from Student where DepartmentName = 'DepartmentOfElectricalEngineering'?
 
1 every time but i have more data in the table with electrical department
 
OK, but when it's just the select you have more than 1 row, correct?
One question: Is this MSSQL? MySQL? Oracle?
 
MSQL
yes i have more rows
thanks for your time
i will try it with some thing else
 
9:27 PM
Hey guys, I'm just wondering if I had a table that contained the following orderID, productName, unitPrice, orderdate, requireddate, shippeddate, employeeID, firstName, lastName and I had to submit a full sequence of SQL statements required to non-loss decompose this table into a set of tables which are in 3NF. How would I go about doing this?
 
First: Do you know what 3NF all requires?
 
I believe i have to follow Heath's Theorem.
I also have to at each step, say how I have followed Heath's Theorem, and state a previously declared functional dependency I am using.
and finally state how I have determined each table to be in 3NF
 
This sounds an awful lot like homework.
 
It's a sample question for my exams that are taking place in 2 weeks
 
I see.
 
9:32 PM
It's just something I have struggled with during term to get to grips with.
any help would be greatly appreciated.
 
The first thing thing you need to do (if you haven't) is familiarize yourself with 3NF.
Then you should redesign the database to conform.
Then you write SQL to transform the data.
 
Well that is fairly straightforward but like I said I have been struggling to come to terms with it. I know people say it's The Key, the whole key and nothing but the key, so help me Codd but i can't get my head around it.
 
That describes the relationship between a non-key field and the primary key. The field should be dependent on the primary key, the whole key, and nothing but the key.
 
ok
 
Do you understand 3NF?
 
9:42 PM
All non-key fields must be
irreducibly dependant on the primary key
Mutually independent
 
Yup. I couldn't name everything from memory, but that looks right.
3NF also includes 2NF and 1NF
 
1NF = Effectively means that each “cell” of a table can contain one-value, and one-value only.
 
10:02 PM
I'm stil lost though.
 
10:16 PM
Maybe your teacher can explain it to you.
 
Yeah I might shoot him an e-mail. It's just we're on study week for the next two and no more lectures. Not to worry. Thanks for your time anyway.
 

« first day    last day (4318 days later) »