Showing posts with label anywhere. Show all posts
Showing posts with label anywhere. Show all posts

Monday, March 26, 2012

HAVING clause is a case statement??

i have wrote a query which compares two tables, returning anywhere the qty is not the same in each table:

(simple ex)

Select order_no
from table1
inner join table2
on table1.order_no = table2.order_no
group by order_no
having table1.Qty<> table2.Qty

BUT... I need to add a table3, where there maybe (or may not be enters - thus a left join). If there is an entry in table3 then use qty in table3 and not table1... so having becomes:

CASE WHEN table1.Qty<> table3.Qty
THEN table3.Qty<> table2.Qty
ELSE table1.Qty<> table2.Qty END

but how do i actually write this?perhaps if you would care to explain what you're doing?

are you comparing individual Qty values, or the SUMs?

because the HAVING clause may refer only to columns in the GROUP BY or to aggregate functions|||perhaps if you would care to explain what you're doing?

are you comparing individual Qty values, or the SUMs?

because the HAVING clause may refer only to columns in the GROUP BY or to aggregate functions

Sorry I am trying to compare Sum(qty) for each product in an order (product maybe in the order more than 1ce) I am trying to retrieve any product lines where Sum qties in table1 and table2 are not the same.

However, if stock was not found, then an allocated qty is recorded in table 3...so in this case I want to compare qtyies in table3 and table2
?|||select t1.order_no
, t1.sumqty
, t2.order_no
, t2.sumqty
from (
select order_no
, sum(qty) as sumqty
from table1
group
by order_no
) as t1
full outer
join (
select order_no
, sum(qty) as sumqty
from table2
group
by order_no
) as t2
on t2.order_no = t1.order_no
and t2.sumqty <> t1.sumqtythat's the general strategy -- do your sums in derived tables

for table 3, you're on your own :)

Monday, March 12, 2012

Hardware requirements?

Hey all,

I couldn't find an answer anywhere on the site, if there is one, could you please let me know where to go? Thanks.

Here goes. We receive large csv files, around a million records a month. What we need to do is:
- Of course, import these records
- Be able to run failry heavy reports on around 3 months worth of data (about 3 million records)
- Wanting to store at least a years worth of data

What I need to know:
- What server(s) spec (CPU, HDD, memory, etc) would we need to import and run reports quite fast. Don't want the reports/imports to take days to run. The reports will need to be run by about 3-5 people at the same time
- What OS and database type should I use (I was looking at Windows/Linux and MS SQL/MySQL)
- If we run these types of reports, can we use the same SQL server to run/store other applications (eg. CRM, etc) with no real impact on performance. There would be at least 20 people using the CRM database at the same time.

ThanksHowdy

You need a serious server - HP DL760 quad CPU 16GB RAM ( min ) 2 TB of storage ( or bigger) .

Windows 2003 and SQL 2000 Advanved Server. $$$$$$$

Any other OS's and servers will do same job,. Depends if you want windows or freeware...

Cheers,

SG|||Thanks for that SG. That is some serious power needed.

Just to understand how long it will take. I have a Compaq DL380 with 2GB RAM. Can you tell me more or less how long it will take to generate a report grouping a specific field and doing a total off another field, assuming it is based on the 3 million records?

Thanks|||Huh?

I don't claim to be a hardware expert, but SQL Server shouldn't even sneeze at 3 million records on a mid-range box.

2 TB storage? For 12 million records a year? Assuming about 500 bytes per record that is 180 years of storage.

16 GB or RAM seems like a steep requirement too, but RAM is never wasted on a server...

As far as how long it takes, my desktop SQL Server will churn through 3 million records in less than a second.

Any one else with opinions on this?|||SQL Server Express...

http://blogs.msdn.com/sqlexpress